dimanche 29 novembre 2015

How can I manage OAuth refresh tokens with Laravel?

The Socialiate plugin provides an implementation for OAuth in Laravel, but it seems to be designed for mostly for the purpose of allowing them to not have to make a user account on your own site.

I am making an application that helps manage their Youtube account, meaning the scope of the auth request is broader (which was easy to change) but I also need a refresh token (versus just an access token) for long-term access to their account.

Is there a package out there for Laravel that already handles this? I haven't been able to find one, but maybe I'm searching for the wrong thing.

If not, how should I approach this? When I write my code that interacts with Youtube's API, do I simply need to check whether the access token is expired, and if so, write a function that does an HTTP request to get a new one with the refresh token I have stored in the database? And I guess also extend Socialite to retrieve a refresh token?

I feel like there's got to be a better way that doesn't involve me re-inventing the wheel. Google has the api-client-library for PHP but no one has integrated this into Laravel, and doing so is a bit outside my abilities.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire