omniauth-youtube icon indicating copy to clipboard operation
omniauth-youtube copied to clipboard

No Refresh Token

Open vkhang55 opened this issue 12 years ago • 7 comments

I have the current setting for omniauth-youtube

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET'], { access_type: 'offline', approval_prompt: '' }
end```

However, it is not returning refresh token from auth_hash. It returns

```ruby
...
"credentials" => {
        "token" => "xxxxxxxxx",
        "expires_at" => 1360645863,
        "expires" => true
}
...

Is my setting wrong or do I need to request for users' refresh tokens specifically?

vkhang55 avatar Feb 12 '13 04:02 vkhang55

Hi,

I have same problem.

Netherdrake avatar Mar 01 '13 11:03 Netherdrake

I have patched my local version of this gem. I will submit commit asap as I learn how to use git/github next week.

The issue was that 'access_type' was never defined in request to Google Oauth. https://developers.google.com/youtube/2.0/developers_guide_protocol#OAuth2_Server_Side_Web_Applications_Flow

Netherdrake avatar Mar 01 '13 12:03 Netherdrake

hi @Netherdrake i think you have to keep options under :authorize_params here is an example -

config.omniauth :youtube,
                    config_hash[Rails.env]['client_id'],
                    config_hash[Rails.env]['secret'],
                    authorize_params: { access_type: 'offline', approval_prompt: 'force' }

we4tech avatar Mar 04 '13 13:03 we4tech

@we4tech Yes, that is correct.

But I have a bit complicated use case so I've tweaked it so authorize_params are not passed in initializer, but rather on demand.

Netherdrake avatar Mar 04 '13 13:03 Netherdrake

Sounds good :)

Sent from my iPad

On Mar 4, 2013, at 7:52 PM, Netherdrake [email protected] wrote:

@we4tech Yes, that is correct.

But I have a bit complicated use case so I've tweaked it so authorize_params are not passed in initializer, but rather on demand.

— Reply to this email directly or view it on GitHub.

we4tech avatar Mar 04 '13 15:03 we4tech

I'd be happy to merge a patch that allowed specifying this via params or otherwise. Thanks for reporting

jamiew avatar Mar 04 '13 16:03 jamiew

I'd be happy to use this patch :)

krichtof avatar May 07 '13 23:05 krichtof