Gmail API:如何获取访问令牌? [英] Gmail API: How to get access token?

查看:130
本文介绍了Gmail API:如何获取访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试 Gmail API



到目前为止,我完成了以下工作:


  • 我已经在 Google Developers Console

  • 我已启用 Gmail API

  • 我创建了一个新的客户端ID 客户端密钥

  • 在我的PHP脚本中,我已经安装了PHP客户端库并遵循
    PHP设置说明现在当我运行文件快速入门时。它提供了一个链接。当我打开它时,它会显示一个授权页面,我可以授权我的应用程序访问Gmail API。然后重定向到我在设置中声明的重定向URI(添加代码参数)。
    $ b


    $ b

    在地址栏中,它恰好显示为:

    http:// localhost / main / gmail_callback?code = MY_CODE



    其中 main 是我的控制器和 gmail_callback 到目前为止只是一个空白函数。



    它应该是正确的,因为这些是我的设置:




    • Javascript来源: http:// localhost

    • 重定向URI : http:// localhost / main / gmail_callback



    我接下来做什么?

    解决方案

    基本上,我错误地接近了。遵循这些说明足以获得令牌:



    https://developers.google.com/gmail/api/quickstart/php



    主要观点是从文件访问命令行,而不是从应用程序。


    I am testing the Gmail API.

    So far I have done the following:

    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:如何获取访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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