Description
Hi,
I'm sorry in actually opening an issue, but I posted my question already in 3 different websites (laravel.io, laracasts and stackoverflow) for more than 2 weeks and didn't get any response so far.
I want to change the way that the access_token is generated, because I want to integrate the FCM (Firebase Cloud Message) in the laravel. FCM works with tokens and there are no reason to not use the same token for Laravel Authentication and push notification(via FCM). I don't think that creating a new table just for that(integrating user with FCM Token) is the best option, at least I hope that is not. :)
So, this is the code to generate the FCM token. Once that is authenticated, the 1 hour expiration date is removed and the token is valid until I logout it from FCM.
How can I add this piece of code in the passport access_token generator?
function FCMTokenGenerator() {
$service_account_email = "[email protected]";
$private_key = "-----BEGIN PRIVATE KEY-----\nMY_OWN_PRIVATE_KEY\n-----END PRIVATE KEY-----\n";
$now_seconds = time();
$payload = array(
"iss" => $service_account_email,
"sub" => $service_account_email,
"aud" => "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iat" => $now_seconds,
"exp" => $now_seconds+(60*60), // Maximum expiration time is one hour
"uid" => "MY_USER",
"claims" => array(
"premium_account" => false
)
);
return JWT::encode($payload, $private_key, "RS256");
}
Any help would be very appreciated! Also, if there are any other community that is more active about this in the internet, I'm willing to post there as well.
Thanks,
Joao