I need help understanding why I can't get info from distribution api.
I already check that I have the api enabled in the console, I double checked the service account to make sure its correct and everything seems ok
var credential = GoogleCredential.FromJsonParameters(new JsonCredentialParameters()
{
Type = "service_account",
ProjectId = "myApp",
PrivateKeyId = "************",
PrivateKey =
"-----BEGIN PRIVATE KEY-----key-----END PRIVATE KEY-----\n",
ClientEmail = "firebase-adminsdk-fbsvc@*******.iam.gserviceaccount.com",
ClientId = "**************",
TokenUri = "https://oauth2.googleapis.com/token",
UniverseDomain = "googleapis.com"
})
var token = await Credential.UnderlyingCredential.GetAccessTokenForRequestAsync("https://accounts.google.com/o/oauth2/auth");
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
string url = "https://firebaseappdistribution.googleapis.com/v1/projects/myApp/apps/myApp/releases";
HttpResponseMessage response = await client.GetAsync(url);
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + result);
}
}
catch(Exception e)
{
}
I'm trying to access firebase distribution api to see the latest release I have but the request is always throwing a 401 saying
Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential
I don't really know what im doing wrong