Monday, April 10, 2017

Manually change the token generated by Laravel

I do have laravel+passport working fine with my app(mobile+website). I do the oauth authentication and get the access_token. However, I want to use FCM(Firebase Cloud Message) to send push notification. And FCM have his own token or either his own way to generate the token.

I'm thinking that in instead of generate a FCM token in my device and then send it to the server and have a separate table only to connect user token (One user can access using different devices, which means that I purposely want to have more than 1 token per user), I would generate a customToken in the server and use this one as the laravel+Passport token and then the device only needs to register using this token.

So, my question would be:

  • How can I change the way that the passport toke is generated in the server? Do I need to change it in the vendor folder?

    OR

  • If its not correct this option above, I was thinking in authenticate user and send a passport token, then in the device request a FCM token and then resend, using the passport token to validate the request a new token. How can I manually change the token generated for the one that I received from the client?

Thanks, joao



via joao.sauer

Advertisement