Google Oauth 同意屏幕未显示
Google Oauth consent screen doesn't show up
我正在尝试按照 Google Oauth 指南授予我的 Rails 应用编辑用户日历的权限。可能我理解错了,guide好像是说你只需要向GoogleAPI发送某个请求,就会弹出同意界面为用户。但是,我发送的请求没有错误,但没有任何反应。
我的应用程序已经过验证,我正在尝试的 URL 已添加到我的 Oauth 凭据中。从理论上讲,在这种情况下应该无关紧要,但我还安装了 'google-api-client'、'omniauth' 和 'omniauth-google-oauth2' gem。 URL 是带有 SSL 证书的 HTTPS。
我做错了什么?
# this is the controller action for my path, so the API is pinged when the page is loaded
def path
url = "https://accounts.google.com/o/oauth2/v2/auth?
scope=email%20profile%20calendar.events&
response_type=code&
redirect_uri=<URL>&
client_id=<CLIENT_ID>"
require 'open-uri'
require 'uri'
require 'net/http'
require 'json'
require 'net/https'
uri = URI(url)
response = Net::HTTP.get(uri)
end
指南有点混乱。他们说 "send a request to the URL https://accounts.google.com/o/oauth2/v2/auth" 但实际上是 "open that URL in a browser"。我想这就是你误解的地方。
因此,创建这个 html 文件:
<a href="https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile%20calendar.events&response_type=code&redirect_uri=REDIRECT_URI&client_id=CLIENT_ID">Login
with Google</a>
现在在浏览器中打开 html 文件并单击 link。您会注意到 Google 服务器将浏览器重定向到您指定的 REDIRECT_URI。您可以在您的 Web 服务器日志中看到(如果服务器正常工作)或者浏览器将显示一条错误消息,您可以在浏览器地址栏中看到 URL 以及 Google 发送的所有查询参数.
在文档中查看您的服务器必须响应重定向的请求,以便最终显示同意屏幕。
当它出现时,过程是相似的:您 - 作为用户 - 授予请求的权限,当您单击按钮时,Google 将再次响应重定向,然后您收获来自查询参数的令牌。