{"action":"closed","issue":{"url":"https://api.github.com/repos/Fullscreen/yt/issues/189","labels_url":"https://api.github.com/repos/Fullscreen/yt/issues/189/labels{/name}","comments_url":"https://api.github.com/repos/Fullscreen/yt/issues/189/comments","events_url":"https://api.github.com/repos/Fullscreen/yt/issues/189/events","html_url":"https://github.com/Fullscreen/yt/issues/189","id":85143978,"number":189,"title":"Automatic refresh of access tokens not working when using omniauth-google-oauth2 gem","user":{"login":"karianne","id":133878,"avatar_url":"https://avatars.githubusercontent.com/u/133878?v=3","gravatar_id":"","url":"https://api.github.com/users/karianne","html_url":"https://github.com/karianne","followers_url":"https://api.github.com/users/karianne/followers","following_url":"https://api.github.com/users/karianne/following{/other_user}","gists_url":"https://api.github.com/users/karianne/gists{/gist_id}","starred_url":"https://api.github.com/users/karianne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karianne/subscriptions","organizations_url":"https://api.github.com/users/karianne/orgs","repos_url":"https://api.github.com/users/karianne/repos","events_url":"https://api.github.com/users/karianne/events{/privacy}","received_events_url":"https://api.github.com/users/karianne/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-04T15:20:05Z","updated_at":"2015-06-08T23:17:41Z","closed_at":"2015-06-08T23:17:41Z","body":"I'm struggling to get automatic refresh of access tokens to work. I'm on the newest version of the Yt gem, and I'm using the `omniauth-google-oauth2` gem and Rails 4.2 as well. This is the code and what it outputs:\r\n\r\n    2.2.2 (main):0 > account = Yt::Account.new refresh_token: <my_token>\r\n    => #<Yt::Models::Account:0x007fc734007e88\r\n    @access_token=nil,\r\n    @authentication=nil,\r\n    @authorization_code=nil,\r\n    @device_code=nil,\r\n    @expires_at=nil,\r\n    @force=nil,\r\n    @redirect_uri=nil,\r\n    @refresh_token=\"<my_token>\",\r\n    @scopes=nil>\r\n    2.2.2 (main):0 > account.email\r\n    Yt::Errors::Unauthorized: A request to YouTube API was sent without a valid authentication:\r\n    {}\r\n\r\n    You can retry the same request manually by running:\r\n\r\n\r\n\r\n    from /Users/karianneberg/code/yt/lib/yt/associations/has_authentication.rb:91:in `rescue in use_refresh_token!'\r\n\r\nWith these initializers:\r\n\r\n    Yt.configure do |config|\r\n       config.api_key = ENV['GOOGLE_API_KEY']\r\n       config.log_level = :devel\r\n     end\r\n\r\n    Rails.application.config.middleware.use OmniAuth::Builder do\r\n      provider :google_oauth2,\r\n           ENV['GOOGLE_CLIENT_ID'],\r\n           ENV['GOOGLE_CLIENT_SECRET'],\r\n           scope: 'userinfo.profile,youtube.readonly,yt-analytics.readonly,youtubepartner-content-owner-readonly,youtubepartner',\r\n           prompt: 'consent'\r\n    end\r\n\r\nPlease note that the client id and secret are set on the Omniauth middleware, not in `Yt.configure`. This seems to work for everything I've tried to do so far (fetching videos, fetching channels, fetching stats etc) except the refreshing of access tokens using refresh token. A workaround is to set the id and secret directly in `Yt.configure` as well, but that seems redundant. \r\n\r\nIs this intended behaviour, or a bug?"}}