Youtube Data API V3刷新Ruby中的访问令牌

时间:2017-06-22 18:52:23

标签: ruby api youtube

我目前正在尝试获取刷新访问令牌。但是,我正在尝试这样做的方式会在指示的行中产生错误。有没有人对此有所了解?

app.get '/youtube_auth' do
            client_secrets = Google::APIClient::ClientSecrets.load
            auth_client = client_secrets.to_authorization
            auth_client.update!(
                :scope => 'https://www.googleapis.com/auth/youtube.force-ssl',
                :redirect_uri => "https://0bba4895.ngrok.io/youtube_auth",
                :additional_parameters => {
                    "access_type" => "offline",         # offline access
                    "approval_prompt" => "force",
                    "include_granted_scopes" => "true"  # incremental auth
                }
            )
            if request['code'] == nil
                auth_uri = auth_client.authorization_uri.to_s
                redirect auth_uri
            else
                auth_client.code = request['code']
                auth_client.fetch_access_token!  # THIS IS CAUSING THE ERROR
                auth_client.client_secret = nil
                session[:credentials] = auth_client.to_json # set my session 
                redirect '/oauth_done'
            end
        end

我得到的具体错误是{ "error" : "invalid_request", "error_description" : "Parameter not allowed for this message type: access_type" }

任何提示都将不胜感激!

0 个答案:

没有答案