rest - 谷歌设备认证后转发用户
问题描述
我有用户使用OAuth2ForDevices方法链接他们的 Google 套件帐户。将帐户链接到设备后,我想将用户转发到带有说明的另一个页面,而不是将它们留在通用谷歌页面“成功!设备已连接”。
这是当前的流程:
1) 从 POST 获取 device_code 和 user_code到 URL:https ://accounts.google.com/o/oauth2/device/code
curl -X POST \
https://accounts.google.com/o/oauth2/device/code \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'client_id=<hidden>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar'
回复
{
"device_code": "ab-cdef...",
"user_code": "ABCD-ABCD",
"expires_in": 1800,
"interval": 5,
"verification_url": "https://www.google.com/device"
}
如果我附加诸如foo=bar或forward_url=之类的参数,则响应仍然与上面相同。
redirect_uri= http://localhost:8080会报错,所以这个参数显然是被识别的。
{
"error": "invalid_request",
"error_description": "Invalid redirect URI"
}
问题似乎不是 URL,因为以下请求工作正常:我管理 t
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=<client_id>&redirect_uri=http://localhost:8080&scope=https://www.googleapis.com/auth/calendar
2)让用户确认verification_url(https://www.google.com/device)
3)“成功!设备已连接”
我尝试了一堆域和 URL:s 已在谷歌搜索控制台中确认并添加到https://console.cloud.google.com中的域验证
值得一提*:我注意到谷歌云平台的行为方式很奇怪,删除了早期验证的域——当我添加新域时:https ://console.cloud.google.com/apis/credentials/domainverification?project= &pli=1&authuser=1
我的理论:1)在使用OAuth2ForDevices方法时,根本不可能添加 redirect_uri 。2) Google Cloud Platform 中有一个错误*,它显示我的域,但这是缓存数据。
解决方案
推荐阅读
- ms-access - 移动到字符串末尾的下一个控件
- python - 如何让 libdrmaa.so 使用本地安装的 GLIBC?
- gstreamer - Gstreamer:当动态添加管道中的元素之一时,“src”元素任务进入暂停状态
- java - Java:在 Jar 中打开 xml-File。无法打开它
- xml - 使用 PowerShell 通过 XML 循环
- android - 如果从 Bintray 存储库获取 lib 但从 Jcenter 获取时不会出错
- android - 如何最小化(隐藏)只是一个特定的活动,而不是整个应用程序
- memory - STM32 IAP应用跳转条件不满足
- reactjs - TypeError: undefined is not an object (evalating 'this.props.location') [ReactJS + react-router-dom V4]
- java - 我需要几乎以这种方式设置JButton颜色,帮助: