I would like to get/set realtime database rules using Rest API however no tutorial is working for me. I try to do it like that:
- I copied the url to my realtime database which is in Europe
https://my-project-database.europe-west1.firebasedatabase.app/ - I copied the java code from this tutorial: https://firebase.google.com/docs/database/rest/auth which was supposed to give me the access token
val googleCred = GoogleCredential.fromStream(File("/path/to/my/key.json").inputStream())
val scoped = googleCred.createScoped(
Arrays.asList( // or use firebase.database.readonly for read-only access
"https://www.googleapis.com/auth/firebase.database",
"https://www.googleapis.com/auth/userinfo.email"
)
)
scoped.refreshToken()
val token = scoped.accessToken
println(token)
However the token looks very strange with a long string of dots at the end like (it's related to: Why am I getting a JWT with a bunch of periods/dots back from Google OAuth?)
ya29.c.Kp8BCgi0lxWtUt-_[Normal JWT stuff, redacted for security]yVvGk...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
- I did HTTP GET to address like
https://my-project-database.europe-west1.firebasedatabase.app/.settings/rules.json?access_token=$tokenand I got 401 UNAUTHORIZED
I assume it's due to the fact that I use the whole of this strange token full of dots as the access_token variable. So now I have questions how to transform it and use as the access_token to make it work
EDIT: I created this gist although it's in python it has exactly the same problem. How to make it work ? https://gist.github.com/solveretur/86d53a9c0221f096c38c3ef8f70a8dbd