"Using Oauth 2.0 for Login" doc将“托管域”参数列为有效的身份验证参数,但使用底部链接的Google API Client for Ruby我看不到如何将其与请求一起传递。有人有例子吗?
答案 0 :(得分:1)
好的,不完美,但我把它传递给了授权对象的authorization_uri属性,如此
client = Google::APIClient.new
client.authorization.authorization_uri(:hd => 'my_domain')
我仍然无法更新Addressable :: URI对象以保存更改(继续获得“数组与阵列的比较失败”错误),但这对我来说已经足够了。
答案 1 :(得分:0)
我无法使用Google :: APIClient让它工作,但设法使用这样的OAuth2 :: Client
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 /令牌” })
...
重定向client.auth_code.authorize_url(:redirect_uri => redirect_uri,:scope => SCOPES,:hd =>'yourdomain.com')