Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change way of generate the access_token. #344

Closed
joaosauer opened this issue Apr 11, 2017 · 1 comment
Closed

Change way of generate the access_token. #344

joaosauer opened this issue Apr 11, 2017 · 1 comment

Comments

@joaosauer
Copy link

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

@themsaid
Copy link
Member

themsaid commented Jul 5, 2017

Closing for lack of activity, hope you got the help you needed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants