首页 文章

创建令牌请求时获取invalid_client响应

提问于
浏览
0

我按照谷歌提供的文档使用API访问gmail . 根据谷歌文档,我们需要访问令牌来管理Gmail .

所以我尝试通过阅读下面给出的文档链接来创建访问令牌 .

Link1: - developers.google.com/accounts/docs/OAuth2WebServer,根据此文档创建了URL1 .

Link2: - code.google.com/p/google-mail-oauth2-tools/wiki/OAuth2DotPyRunThrough,根据此文档创建了URL2 .

URL1: - https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&state=%2Fprofile&redirect_uri=http%3A%2F%2Flocalhost%2Fstudy%2Fgmail-access%2Foauth2-php-samples%2Foauth2.php&response_type=code&client_id=XXXXXXXXXXXXXXX.apps.googleusercontent.com&approval_prompt=force

URL2: - https://accounts.google.com/o/oauth2/auth?client_id=XXXXXXXXXX.XXXXapXps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%2Fstudy%2Fgmail-access%2Foauth2-php-samples%2Foauth2.php&response_type=code&scope=https%3A%2F%2Fmail.google.com%2F

我在两个请求中都收到了无效的客户端响应 . 请帮我找到获得无效客户响应的原因 .

1 回答

  • 0

    我不确定URL1的问题,但更换重定向uri和客户端ID后令牌正确

    URL2不正确,因为我使用了Web应用程序的客户端ID而不是已安装的应用程序 .

    据我所知,https://code.google.com/p/google-mail-oauth2-tools/wiki/OAuth2DotPyRunThrough中的说明有助于为已安装的应用程序而不是Web应用程序创建令牌 .

相关问题