无法在 POSTMan 上获取 Google oAuth 2 令牌 [英] Could not obtain Google oAuth 2 token on POSTMan

查看:25
本文介绍了无法在 POSTMan 上获取 Google oAuth 2 令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,由于 其他问题(已解决)仍未解决,我想使用POSTMan对Client库将要执行的每个步骤进行试错.

Well, since the Other problem(solved) remain unsolved, I was thinking to use POSTMan to do Trial and Error on each steps that the Client library will do.

所以我再次阅读了 Google OAuth2 的基本步骤,创建了另一个开发控制台Api Manager > Credentials中的OAuth 2 ID,ID类型为Web Application,填入POSTMan:

So I read the Basic steps of Google OAuth2 again, created another OAuth 2 ID at Api Manager > Credentials in Dev Console and ID type is Web Application, and filled them into the POSTMan:

  1. POSTMan 中的新选项卡,然后单击授权标签.
  2. 选择类型为 OAuth 2.0 并选择向 url 添加令牌"
  3. 身份验证网址:https://accounts.google.com/o/oauth2/v2/auth
  4. 访问令牌网址:https://www.googleapis.com/oauth2/v4/token
  5. 客户 ID:[我刚刚收到的客户 ID]
  6. 客户端密码:[我刚刚收到的客户端密码]
  7. 范围:[空]
  8. 授权类型:授权码
  9. 在本地请求访问令牌:已选择
  10. 点击请求令牌"
  11. 邮递员回复我:无法完成 OAuth2.0 登录"

我错过了什么吗?

(可以在此处找到 Google 重定向 URI)

(Google redirect URI could be found here)

(可以在此处找到 API 范围)

(API scope could be found here)

推荐答案

只有当 Google 用户通过 google 登录页面登录时,您才能获得访问令牌.

You get access Token only when a Google User Logs in through the google signin page.

第 1 步:重定向https://accounts.google.com/o/oauth2/auth?client_id=" + GoogleClientID + "&redirect_uri=" + Url.Encode(GoogleRedirectURL) + "&response_type=code&scope=email"

Step 1: Redirect https://accounts.google.com/o/oauth2/auth?client_id=" + GoogleClientID + "&redirect_uri=" + Url.Encode(GoogleRedirectURL) + "&response_type=code&scope=email"

第 2 步:现在您在 google 登录页面上,您将输入您的 google 凭据.

Step 2: Now you are on google signin page and you would enter your google credentials.

第 3 步:Google 会将您重定向回您在 Google Developer Console 中配置的 redirect_uri,您可以从 QueryString 中获取代码"

Step 3 : Google will redirect you back to the redirect_uri that you have configured in the Google Developer Console and you can get the "code" from the QueryString

第 4 步:现在您将表单发布到 https://www.googleapis.com/oauth2/v4/token使用 client_id、client_secret、redirect_uri、代码(您在第 3 步中获得)和 grant_type=authorization_code

Step 4: Now you post a form to https://www.googleapis.com/oauth2/v4/token with client_id, client_secret, redirect_uri, code(you obtained in Step 3), and the grant_type=authorization_code

结果:您现在应该会收到来自 Google 的 access_token

Result: You should now receive the access_token from Google

这篇关于无法在 POSTMan 上获取 Google oAuth 2 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆