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

Support a callback when access token generated from refresh token #300

Closed
Scorcher opened this issue Aug 30, 2014 · 6 comments
Closed

Support a callback when access token generated from refresh token #300

Scorcher opened this issue Aug 30, 2014 · 6 comments
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Scorcher
Copy link

I am using OAuth2 to make offline request to YouTube API...
When this library refreshes an access_token using refresh_token it would be very useful to call user specified callback to make possibility storing new token somewhere in centralized storage of application.
Now I should check token changes after each exec of my script to reduce refresh.

For example:

$client = new Google_Client();
$client->setOnRefreshTokenCallback(<lambda from my code>);
@ianbarber ianbarber changed the title Oauth2: onRefreshTokenCallback Support a callback when access token generated from refresh token Sep 8, 2014
@ianbarber ianbarber added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Sep 8, 2014
@dmyers
Copy link

dmyers commented Jan 19, 2015

What is the purpose of having the package refresh the token? Can we currently detect the change and store it?

@Scorcher
Copy link
Author

Yes, you can. You should check token changes after each call to Google API. If changed - store it and use new one next time. If you will use old one (ignoring changes) - the library will update token every time (it is one more request).

See these two sections for detailed understanding: https://developers.google.com/accounts/docs/OAuth2WebServer#offline

@bshaffer
Copy link
Contributor

please see #905

@tmatsuo
Copy link

tmatsuo commented Jan 9, 2017

Can we close this now? #905 seems merged.

@tmatsuo
Copy link

tmatsuo commented Jan 9, 2017

Closing. Feel free to re open if you think differently

@tmatsuo tmatsuo closed this as completed Jan 9, 2017
@bshaffer
Copy link
Contributor

bshaffer commented Jan 9, 2017

Yep! This is available via Google_Client::setTokenCallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants