songkick / oauth2-provider

Simple OAuth 2.0 provider toolkit
MIT License
528 stars 148 forks source link

Getting token information #55

Closed lloydmeta closed 11 years ago

lloydmeta commented 11 years ago

Hi,

Thanks for building this library. Found it quite easy to integrate with my project thus far.

My question is: Given that I only have an access_token (because using a Javascript client, I'm sending a user to the authorize endpoint and the user has already previously authorized my app), is there any way for me to retrieve the refresh token and expires_in values for it?

I suppose I can create a separate endpoint that returns these values to my client, but I'm wondering if there is already a built-in easier way.

Thanks,

Lloyd

jcoglan commented 11 years ago

Those values should be returned along with the access token on authorization. This library does not implement refresh tokens but it does implement expiry. If you pass the :duration option to grant_access!:

authorization.grant_access! :duration => 1.hour

Then the request that returns the access_token will also return an expires_in parameter that indicates the remaining lifetime of the token in seconds. If you don't set :duration then the token has infinite lifetime and no expires_in value is sent to the client.

lloydmeta commented 11 years ago

Ah, got it thanks !