使用邮递员访问OAuth 2.0 Google API [英] Using Postman to access OAuth 2.0 Google APIs

查看:174
本文介绍了使用邮递员访问OAuth 2.0 Google API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用



我下载了这个,但是如果我使用邮差,这没什么帮助。我猜这个JSON文件是可以包含在JS应用程序中的。




  • 步骤3 - 使用Postman测试API





我收到了什么?



而且,一旦我点击调试网址,我看到下面的屏幕



解决方案

div>

到目前为止,我发现的最佳方式是到这里的Oauth游乐场: https://开发人员。 google.com/oauthplayground/


  1. 选择相关的google api分类,然后在UI中选择该分类中的范围。
  2. 通过点击授权API蓝色按钮来获取授权码。
    通过单击蓝色按钮交换令牌的授权代码。

  3. 存储OAuth2令牌并按照如下所示使用它。

在REST API请求的HTTP标头中,添加:授权:承载者。在这里,授权是关键,而承载。例如:授权:持票人za29.KluqA3vRtZChWfJDabcdefghijklmnopqrstuvwxyz6nAZ0y6ElzDT3yH3MT5


I am trying to access Proximity Google API using Postman chrome app. I have followed tutorials on postman and google dev website but I'm still getting 401 error message.

What am I doing?

  • Step 1 - Enable Proximity API:

In order to use Proximity API, it has to be first enabled in Google Dev console. Using this tutorial I have enabled support for Proximity API for my project

  • Step 2 - Get the credentials:

According to this tutorial, I need to get client ID and secret. This is where I am confused. Credentials->Add credentials->OAuth2.0 client ID->select Chrome App radio button (since I am using Postman)->enter last part of Postman's Chrome Web store URL [which is fhbjgbiflinjbdggehcddcbncdddomop]->hit create button These steps will only generate a client ID, not a secret..am I doing something wrong?

From the Google Dev console, one can download an JSON file which has client id, auth URI and Token URI

I downloaded this but this is of little help if I am using Postman. I am guessing this JSON file is something that can be included in a JS application.

  • Step 3 - Use Postman to test the API

What am I getting?

And, once I click on the debug URL, I see the following screen

解决方案

The best way I found so far is to go to the Oauth playground here: https://developers.google.com/oauthplayground/

  1. Select the relevant google api category, and then select the scope inside that category in the UI.
  2. Get the authorization code by clicking "authorize API" blue button. Exchange authorization code for token by clicking the blue button.
  3. Store the OAuth2 token and use it as shown below.

In the HTTP header for the REST API request, add: "Authorization: Bearer ". Here, Authorization is the key, and "Bearer ". For example: "Authorization: Bearer za29.KluqA3vRtZChWfJDabcdefghijklmnopqrstuvwxyz6nAZ0y6ElzDT3yH3MT5"

这篇关于使用邮递员访问OAuth 2.0 Google API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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