Google has recently started to give us a Json key file for service account instead of the P12 key file. I have been trying to get this there isn't a lot of information out there and what info I have seen says this should work.
string[] scopes = new string[] { DriveService.Scope.Drive};
Stream stream = new FileStream(jsonKeyFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var credential = GoogleCredential.FromStream(stream).CreateScoped(scopes);
However its throwing the following exception
Error creating credential from JSON. Unrecognized credential type .
I have double checked the json key file downloaded two different ones trying to get it to work nothing.
I think you are using file google-services.json
downloaded from Firebase. This isn't file you need. Process you have to do is:
I downloaded a Service Account json key file and tried the same code and it works fine. I was able to replicate the issue if I manually corrupted the "type" field in the json key file. Can you re-download a json key file and try again. Here is what the json key file should look like (sensitive data removed):
{
"type": "service_account",
"project_id": ...,
"private_key_id": ...,
"private_key": ...,
"client_email": ...,
"client_id": ...,
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With