rest - 如何使用 OAuth 2 实现静默登录并从 google 获取代码/令牌
问题描述
我是谷歌誓言的新手,
参考google的文档
当我生成登录 URL 示例时
https://accounts.google.com/o/oauth2/auth?
redirect_uri=http://www.mywebapp.com/oauth2callback&
response_type=code&
client_id=104608secret-secret-secret-secret.apps.googleusercontent.com&
scope=https://www.googleapis.com/auth/analytics.readonly+https://www.googleapis.com/auth/userinfo.email&
approval_prompt=force&
access_type=offline
这将重定向到显示谷歌电子邮件 ID的接受页面
当用户点击“接受”时,谷歌会将用户重定向到您给定的redirect_url
当我使用 chrome 和 https://developers.google.com/oauthplayground/ 因为它重定向屏幕接受。一切都会好起来的。
但是当我使用邮递员时,它不会返回谷歌的“访问码”
我在 url 参数中做错了什么。
我必须使用上面的 url 创建休息服务。
我已经搜索了 如何获取虚拟谷歌访问令牌来测试 oauth google api? 如何验证 Google 身份验证 API 访问令牌? https://developers.google.com/identity/protocols/OAuth2 https://www.themarketingtechnologist.co/google-oauth-2-enable-your-application-to-access-data-from-a-google-user /
但是没有解释关于静默登录以获取令牌而不接受屏幕
解决方案
您的回调 url 收到一个“代码”。
然后你需要用你的“代码”换取访问令牌。
https://aaronparecki.com/oauth-2-simplified/
推荐阅读
- php - 如何从下拉列表中在购物车中添加价格
- swift - SwiftUI 视图层次结构中较高的动画覆盖嵌套动画
- c++ - 无法从 SQLite 数据库中检索数据并在 QT GUI 上显示
- javascript - 无法弄清楚我的代码有什么问题(getElementsByClassName,Javascript 按钮)
- azure - 应用服务计划在 azure devops 的发布管道期间无法覆盖应用设置中的嵌套 JSON 键
- javascript - 将 MongoDB 与流星一起使用的问题
- http - HTTP Content-Security-Policy 是按页面还是按 GET 设置的?
- reactjs - 如何在子容器组件中初始化相同命名的道具
- makefile - 用于编译 CUDA 源 (.cu -> .cu.o) 的隐式规则弄乱了 Makefile
- r - 我可以修复在 r 中安装二进制构建的错误吗?