如何使用 Google Ruby API Client 传入 OpenID Connect (Oauth2 Login) 的'hd'选项?



"Using Oauth 2.0 for Login"文档列出了'托管域'参数作为一个有效的身份验证参数,但是使用底部链接的Google API Client for Ruby,我不知道如何将它与我的请求一起传递。有人能举个例子吗?

好的,不是很完美,但我只是把它传递给授权对象上的authorization_uri属性,像这样

client = Google::APIClient.new 
client.authorization.authorization_uri(:hd => 'my_domain')

我在更新Addressable::URI对象以保存更改时仍然遇到麻烦(不断得到"数组与数组的比较失败"错误),但这对我来说已经足够好了。

我不能让它工作使用谷歌::apicclient,但设法让它工作使用OAuth2::客户端像这样

SCOPES = ["https://www.googleapis.com/auth/userinfo.email"]。加入(' ')

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"})

重定向client.auth_code。authorize_url(:redirect_uri => redirect_uri,:scope => SCOPES,:hd => 'yourdomain.com')

最新更新