问题描述
我正在测试。
到目前为止,我完成了以下工作:
- 我已经在
- 我已启用
Gmail API
。 - 我创建了一个新的
客户端ID
和客户端密钥
。 - 在我的PHP脚本中,我已经安装了PHP客户端库并遵循
。现在当我运行文件快速入门时。它提供了一个链接。当我打开它时,它会显示一个授权页面,我可以授权我的应用程序访问Gmail API。然后重定向到我在设置中声明的重定向URI(添加代码参数)。
$ b
$ b在地址栏中,它恰好显示为:
其中 main 是我的控制器和 gmail_callback 到目前为止只是一个空白函数。
它应该是正确的,因为这些是我的设置:
- Javascript来源:
http:// localhost
- 重定向URI :
http:// localhost / main / gmail_callback
我接下来做什么?
解决方案基本上,我错误地接近了。遵循这些说明足以获得令牌:
主要观点是从文件访问命令行,而不是从应用程序。
I am testing the Gmail API.
So far I have done the following:
- I have created the project in the Google Developers Console
- I have enabled the
Gmail API
. - I have created a new
Client ID
and theclient secret
. - In my PHP script I have installed the PHP Client library and followedthe instructions for the setup in PHP.
So now when I run the file quickstart.php it gives a link. When I open it, it appears an authorization page where I authorize my application to access the Gmail API.
Then it redirects to the Redirect URIs that I have declared in the setup (adding the code parameter).
In the address bar it appears exactly this:
http://localhost/main/gmail_callback?code=MY_CODE
Where main is my controller and gmail_callback so far is just a blank function.
And it should be correct since these are my settings:
- Javascript origins:
http://localhost
- Redirect URIs:
http://localhost/main/gmail_callback
What do I do next?
解决方案Basically I was approaching wrongly. Following these instructions is enough to get the tokens:
https://developers.google.com/gmail/api/quickstart/php
The main point is to access the file from the command line and not from the app.
这篇关于Gmail API:如何获取访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- Javascript来源: