Nov 5, 2022
0
Level 8
FCM access token has lots of periods at the end, how to remove them with PHP code?
in my app I want to use new FCM API, however when I retrieve the service account token on the backend, said access token appears with lots of periods:
I changed some characters but it looks like this:
ya29.c.*********************************************************M7Ml0h5Wv6eSqRF_Q6C2jgGMYTgZjzL5P2cZWqNbxZ4G9Loz3lNALYgGWFW0Gmkf6eRP8oRqVNAoxbsynrNVLWWIjSf6WAymbIK55LS16Bi2hBI9GlUH8V4fRdhsuN44L5DTliz8YxLD91PzHnrqxVyUgZr0gOBuCAGKTIcdvw........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................"
On my laravel backend, this is how I get the acces token from my service account json file, how can I remove the last periods?
public function getGoogleAccessToken()
{
$credentialsFilePath = 'C:\xampp\htdocs\wooloveapp.com\json\myapp-dda64-firebase-adminsdk-a84ay-19eb8e8171.json'; //replace this with your actual path and file name
$client = new \Google_Client();
$client->setAuthConfig($credentialsFilePath);
$client->addScope('https://www.googleapis.com/auth/firebase.messaging');
$client->refreshTokenWithAssertion();
$token = $client->getAccessToken();
return $token['access_token'];
}
Why am I getting the periods at the end? How can I remove with PHP code all the periods at the end of the token?
If I manually remove the periods it works, but I want to remove them programatically with PHP.
Please or to participate in this conversation.