You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Dana Silver
5715f8c53c
|
8 years ago | |
---|---|---|
.. | ||
functions | 8 years ago | |
public | 8 years ago | |
README.md | 8 years ago | |
database.rules.json | 8 years ago | |
firebase.json | 8 years ago |
README.md
Authenticated JSON API
This sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.
Only users who pass a valid Firebase ID token as a Bearer token in the
Authorization
header of the HTTP request are authorized to use the API.
This sample comes with a web-based API explorer UI whose code is in the public directory. It lets you sign in to Firebase with your Google account, and create messages whose sentiments are detected by the Cloud Natural Language API.
Setting up the sample
- Create a Firebase Project using the Firebase Console.
- Enable the Google Provider in the Auth section.
- Enable Billing on your project (to connect to the Natural Language API) by switching to the Blaze or Flame plan.
- Clone or download this repo and open the
authenticated-json-api
directory. - You must have the Firebase CLI installed. If you don't have it install it with
npm install -g firebase-tools
and then configure it withfirebase login
. - Configure the CLI locally by using
firebase use --add
and select your project in the list. - Install dependencies locally by running:
cd functions; npm install; cd -
- Enable the Google Cloud Natural Language API: https://console.cloud.google.com/apis/api/language.googleapis.com/overview?project=_
Deploy and test
This sample comes with a web-based UI for testing the function. To test it out:
- Deploy your project using
firebase deploy
- Open the app using
firebase open hosting:site
, this will open a browser. - Sign in to the web app in the browser using Google Sign-In
- Create messages and explore them using the List and Detail sections.
- Sign out. You should no longer be able to access the API.
Contributing
We'd love that you contribute to the project. Before doing so please read our Contributor guide.
License
© Google, 2017. Licensed under an Apache-2 license.