I am trying to implement the verification token id from server side using Firebase Admin SDK(java), but i am getting the error:
Failed to parse service account: 'project_id' must be set
I generated my credentials in the following path from firebase:
Project settings->Service Accounts and generate a new private key and I have this:
{
"type": "service_account",
"project_id": "apilogintest-9c5f5",
"private_key_id": "<privateKeyId...>",
"private_key": "-----BEGIN PRIVATE KEY-----\n<a really big private Key>\n-----END PRIVATE KEY-----\n",
"client_email": "<clientEmail>",
"client_id": "<clientId>",
"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": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-hhay...."
}
Also the way that I load the JSON file it`s the same as the firebase web page:
for maven:
to load my json file using java:
FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl("https://apilogintest-9c5f5.firebaseio.com/")
.build();
FirebaseApp initializeApp = FirebaseApp.initializeApp(options);
and the last part when i am trying to verify the token id:
FirebaseAuth.getInstance(initializeApp).verifyIdToken(token)
.addOnSuccessListener(new OnSuccessListener<FirebaseToken>() {
@Override
public void onSuccess(FirebaseToken decodedToken) {
String uid = decodedToken.getUid();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
e.printStackTrace();
}
});
I think that i did the same that the firebase web page mentions but i am getting the above error
Can somebody help me?
I would appreciate your help.