0

I need to access my FireBase Database via HTTP and I don't know what should I insert in scope field of the JWT claim set. In the docs, it reads "scope: A space-delimited list of the permissions that the application requests." The path to my Database in Firebase is like https://console.firebase.google.com/project/fir-19f8e/database/data Is this what I should enter in scope?

let jwtClaimSet =
["iss":"firebase-adminsdk-c7i12345@fir-30c9e.iam.gserviceaccount.com",
 "scope":"",
 "aud": "https://www.googleapis.com/oauth2/v4/token",
 "exp": "",
 "iat": ""]

enter image description here

bibscy
  • 2,598
  • 4
  • 34
  • 82

1 Answers1

3

You need the following scopes:

  • "https://www.googleapis.com/auth/firebase.database"
  • "https://www.googleapis.com/auth/userinfo.email"

You can learn more in the Firebase Database REST API User Authentication docs.

jwngr
  • 4,284
  • 1
  • 24
  • 27
  • Anyone who wants to make calls to google API's can find the full explanation how to make JWT and sign them. Also if you get error invalid signature, unsupported grant_type, [here is the answer. It just works](http://stackoverflow.com/questions/40696026/swiftvapor-requesting-oauth-token-for-service-account-with-error-unsupported-gr) – bibscy Nov 22 '16 at 21:41
  • When I try to access Firebase Database, I get error Permission Denied. [I posted the question here](http://stackoverflow.com/questions/40810233). I appreciate your help. – bibscy Nov 25 '16 at 18:01
  • Why is it necessary to give to scopes parameter the value `https://www.googleapis.com/auth/userinfo.email` when we only want to read/write firebase database using an access token received from OAuth2.0 server? I thought `https://www.googleapis.com/auth/firebase.database` would be the only scope needed. – bibscy Nov 27 '16 at 15:59