“使用 Oauth 2.0 登录”文档将“托管域”参数列为有效的身份验证参数,但使用底部链接的Google API Client for Ruby,我看不到如何将它与我的请求一起传递。有人有例子吗?
2 回答
好的,并不完美,但我只是将它传递给授权对象上的 authorization_uri 属性,就像这样
client = Google::APIClient.new
client.authorization.authorization_uri(:hd => 'my_domain')
我仍然无法更新 Addressable::URI 对象以保存更改(不断收到“数组与数组的比较失败”错误),但这对我来说已经足够好了。
I couldn't get it to work using the Google::APIClient but managed to get it working using the OAuth2::Client like this
SCOPES = [ 'https://www.googleapis.com/auth/userinfo.email' ].join(' ')
client ||= OAuth2::Client.new(G_API_CLIENT, G_API_SECRET, { :site => 'https://accounts.google.com', :authorize_url => "/o/oauth2/auth", :token_url => "/o/oauth2/token" })
...
redirect client.auth_code.authorize_url(:redirect_uri => redirect_uri,:scope => SCOPES,:hd => 'yourdomain.com')