Passthru all arguments, including refresh token
Created by: evanhdc
Hi,
My API provider uses a standardized OAuth 2.0 token-based authentication flow. Now I get stuck on finding a way to refresh the access token.
2.7.1 :001 > require 'oauth2'
2.7.1 :002 > client = OAuth2::Client.new('client_id', '', grant_type: 'refresh_token', site: 'site', token_url: 'token_url', redirect_uri: 'redirect_uri')
2.7.1 :003 > client.auth_code.authorize_url(access_type: 'offline')
2.7.1 :004 > tokens = client.auth_code.get_token('auth_code', 'grant_type': 'authorization_code')
2.7.1 :005 > tokens.refresh_token
=> nil
According to the API guide, the response attributes are
{
"access_token": "string",
"expires_in": 0,
"refresh_token": "string",
"refresh_token_expires_in": 0,
}
But as shown in line 5, the tokens.refresh_token was nil. It looks like it's intentional per https://github.com/oauth-xx/oauth2/issues/321. How am I supposed to renew the access token, since a refresh token is required when using refresh token grant?
Here is the error. I waited until the access token expired, then tried to renew it:
2.7.1 :006 > tokens.expired?
=> true
2.7.1 :007 > new_tokens = tokens.refresh!
Traceback (most recent call last):
1: from (irb):95
RuntimeError (A refresh_token is not available)
Did I miss anything?