I am getting OAuth token when I call this Google Cloud function (using node.js) but it seems that I am not getting the correct OAuth token for messaging.
const MESSAGING_SCOPE = 'https://www.googleapis.com/auth/firebase.messaging';
const SCOPES = [MESSAGING_SCOPE];
function getOAuthAccessToken() {
return new Promise(function (resolve, reject) {
let jwtClient = new google.auth.JWT(
keyData.client_email,
null,
keyData.private_key,
SCOPES,
null
);
jwtClient.authorize(function (err, tokens) {
if (err) {
reject(err);
return;
}
resolve(tokens.access_token);
});
});
}
//error payload:
- Pretty-JSON-String: {
"error" : {
"code" : 400,
"message" : "The registration token is not a valid FCM registration token",
"status" : "INVALID_ARGUMENT",
"details" : [
{
"@type" : "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode" : "INVALID_ARGUMENT"
}
]
}
}
Note: I can get it (OAuth access token) in Google playgrounds and it works, but that token is just temp token.
Any input, solution how to get it.