以下是我想要做的 -
client = Google::APIClient.new
client.authorization.client_id = 'XXXX'
client.authorization.client_secret = 'XXXXX'
client.authorization.scope = 'https://www.googleapis.com/auth/calendar'
client.authorization.redirect_uri = 'http://www.aaaaa.com/'
calendar = client.discovered_api('calendar', 'v3')
为了让 access_token 发出进一步的请求,我调用了 client.authorization.fetch_access_token!
我得到的回应是:
Signet::AuthorizationError: Authorization failed. Server message:
{
"error" : "invalid_request"
}
from D:/main/tools/jruby/lib/ruby/gems/1.8/gems/signet-0.4.4/lib/signet/oauth_2/client.rb:865:in `fetch_access_token'
后来我更改了一些更改并将grant_type设置为密码并提供了用户名和密码。
client.authorization.grant_type = 'password'
client.authorization.username = 'aaaaa'
client.authorization.password = 'aaaaa'
仍然面临同样的问题。
文档没有太大帮助。有什么我缺少的设置吗?