似乎是創業板的oauth2如何通過variabels物體內部,模式和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
嘿,我不確定你的問題是什麼?無記名標記是什麼意思? –
請參閱最新的草案7.0(草案20)OAuth2 RFC:「授權:承載7Fjfp0ZBr1KtDRbnfVdmIw」 – Zepplock