jamiew / omniauth-youtube

OmniAuth 1.0 strategy for connecting to YouTube
https://github.com/jamiew/omniauth-youtube
19 stars 18 forks source link

No Refresh Token #8

Open vkhang55 opened 11 years ago

vkhang55 commented 11 years ago

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?

Netherdrake commented 11 years ago

Hi,

I have same problem.

Netherdrake commented 11 years ago

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

we4tech commented 11 years ago

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' }
Netherdrake commented 11 years ago

@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.

we4tech commented 11 years ago

Sounds good :)

Sent from my iPad

On Mar 4, 2013, at 7:52 PM, Netherdrake notifications@github.com 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.

jamiew commented 11 years ago

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

krichtof commented 11 years ago

I'd be happy to use this patch :)