Retrieving new Firebase access token for REST services in .NET from Google auth service
<p>After a change of firebase authorization system, I'm trying to retrieve access token in c# from google auth server.</p>

<p>According to new documentation: <a href="https://firebase.google.com/docs/reference/rest/database/user-auth#section-api-usage">https://firebase.google.com/docs/reference/rest/database/user-auth#section-api-usage</a></p>

<p>I created something similar in c#:</p>

<pre><code>using Google.Apis.Auth.OAuth2;
[...]
async Task&lt;string&gt; 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();
}
</code></pre>

<p>gckey.json is key file downloaded from Google Developer console for specific firebase project.</p>

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

<p>but I receive:
<code>"error" : "Permission denied."</code></p>

<p>What am I doing wrong? Or what I'm missing?</p>