Firebase has decrepated database secret generation for new Apps.
I was using this method to access a database on the server side.
I was trying to generate an auth token using C# but i cannot get examples about this on C#:
Sample code:
RSACryptoServiceProvider provider = new RSACryptoServiceProvider();
provider.ImportPkcs8PrivateKey(privateKeyRaw);
RsaSecurityKey rsaSecurityKey = new RsaSecurityKey(provider);
// Generating the token
var now = DateTime.UtcNow;
var claims = new[] {
new Claim("https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.email"),
new Claim("https://www.googleapis.com/auth/firebase.database", "https://www.googleapis.com/auth/firebase.database")
};
var handler = new JwtSecurityTokenHandler();
var token = new JwtSecurityToken
(
OAuthConfig.client_email,
OAuthConfig.token_uri,
claims,
now.AddMilliseconds(-30),
now.AddMinutes(60),
new SigningCredentials(rsaSecurityKey, SecurityAlgorithms.RsaSha256)
);
handler.WriteToken(token);
Question 1: Are the claims are correct?
Question 2: How do i get the string from the "token" class to pass to the "auth" parameter on my REST API call.
Thanks.
Best regards,
Rui Cruz
question from:
https://stackoverflow.com/questions/66051070/using-firebase-rest-api-calls-without-database-secrets 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…