Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving new Firebase access token for REST services in .NET from Google auth service [duplicate]

Tags:

After a change of firebase authorization system, I'm trying to retrieve access token in c# from google auth server.

According to new documentation: https://firebase.google.com/docs/reference/rest/database/user-auth#section-api-usage

I created something similar in c#:

using Google.Apis.Auth.OAuth2;
[...]
async Task<string> GetToken()
{
    GoogleCredential credential;
    using (var stream = new System.IO.FileStream("gckey.json",
        System.IO.FileMode.Open, System.IO.FileAccess.Read))
    {
        credential = GoogleCredential.FromStream(stream).CreateScoped(
            new string[] { "https://www.googleapis.com/auth/firebase.database" }
            );
    }

    ITokenAccess c = credential as ITokenAccess;
    return await c.GetAccessTokenForRequestAsync();
}

gckey.json is key file downloaded from Google Developer console for specific firebase project.

Code works fine, but it returns token that is not working with firebase, I have tried: https://fiery-torch-xxxx.firebaseio.com/.json?access_token=retrived token

but I receive: "error" : "Permission denied."

What am I doing wrong? Or what I'm missing?


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!