How to manage database rules using REST API

94 views
Skip to first unread message

Przemek Brzeziński

unread,
Sep 4, 2021, 11:03:57 AM9/4/21
to Firebase Google Group
Hi everyone,
my question was posted on: https://stackoverflow.com/questions/69016662/firebase-realtime-database-how-to-manage-database-rules-using-rest-api

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:

```
  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
        )
    )
    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 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

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

KR

Reply all
Reply to author
Forward
0 new messages