使用邮递员访问OAuth 2.0 Google API [英] Using Postman to access OAuth 2.0 Google APIs
问题描述
我尝试使用
我下载了这个,但是如果我使用邮差,这没什么帮助。我猜这个JSON文件是可以包含在JS应用程序中的。
- 步骤3 - 使用Postman测试API
-
我收到了什么?
而且,一旦我点击调试网址,我看到下面的屏幕
到目前为止,我发现的最佳方式是到这里的Oauth游乐场: https://开发人员。 google.com/oauthplayground/
- 选择相关的google api分类,然后在UI中选择该分类中的范围。
- 通过点击授权API蓝色按钮来获取授权码。
通过单击蓝色按钮交换令牌的授权代码。 - 存储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/
- Select the relevant google api category, and then select the scope inside that category in the UI.
- Get the authorization code by clicking "authorize API" blue button. Exchange authorization code for token by clicking the blue button.
- 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屋!