OAuth2与intridearubygem

我有以下代码:

token = client.auth_code.get_token(code, :redirect_uri => 'http://localhost:3000') response = token.get('https://api.foursquare.com/v2/users/self/checkins', {:mode => :query}) 

问题是无论如何:我指定的模式我总是在Authorization标头中获得一个Bearer令牌。 有问题的代码是私有的set_token,它总是依赖于默认:mode,它始终是:header。

我用错了吗?

谢谢!

似乎有一个问题oauth2 gem如何在对象内部传递变量,因此模式和param_name似乎在路上丢失了。 该问题的解决方案是使用正确的参数创建新的AccessToken对象,而不是使用速记。 此示例针对Foursquares api进行了测试,并且可以正常运行。

 require "oauth2" client = OAuth2::Client.new( "CLIENT_ID", "CLIENT_SECRET", :authorize_url => "/oauth2/authorize", :token_url => "/oauth2/access_token", :site => "https://foursquare.com/" ) puts client.auth_code.authorize_url(:redirect_uri => "http://localhost:4000") code = gets.chomp token = client.auth_code.get_token(code, :redirect_uri => "http://localhost:4000") token = OAuth2::AccessToken.new(client, token.token, { :mode => :query, :param_name => "oauth_token", }) response = token.get('https://api.foursquare.com/v2/users/self/checkins') puts response.body