错误:来自google+php快速启动应用程序的invalid_client


Error: invalid_client from google+ quick start app for php

我用google+quickstart应用程序做错了什么?我想我很好地遵守了指示https://developers.google.com/+/quickstart.php(。我使用的是Mac OS 10.8,php版本5.3.15。当我点击登录按钮时,弹出窗口出现错误

错误:invalid_client和请求详细信息。

请注意下面的client_id值,并注意在我浏览器的index.html页面上,标题显示为{{APLICATION_NAME}}:

请求详细信息

response_type=code token id_token gsession
scope=https://www.googleapis.com/auth/plus.login
redirect_uri=postmessage
access_type=offline
cookie_policy=single_host_origin
proxy=oauth2relay2033209164
origin=http://localhost
state=2128268783|0.3526941802619493
client_id={{ CLIENT_ID }}
request_visible_actions=http://schemas.google.com/AddActivity
authuser=0

以下是我所做的,1( 将index.html重命名为index.php2( 已添加`

const CLIENT_ID = '123###.apps.googleusercontent.com';
const APPLICATION_NAME = "Google+ PHP Quickstart";

?>`  to index.php top.

3( 将{{ APPLICATION_NAME }}更改为<?php echo APPLICATION_NAME; ?>,CLIENT_ID更改为4( 在。。。src/config.php我将CLIENT_ID、APPLICATION_NAME和CLIENT_SECRET值添加到$apiConfig数组初始值设定项中,认为这可能无关紧要。

现在这个例子似乎奏效了。我仍然不知道那些双花括号是怎么回事。

任何人对此都有任何想法,请照做,但我想现在已经解决了。

我和你做了同样的事情。页面实际上说要转到浏览器中的signin.php,而不是根目录(index.html(。这将为您正确解析{{XX}}变量。

在默认页面:index.html中,将标题更改为应用程序名称:<title>LiveApp</title>。在主体标签下的按钮类替换

data-clientId={{ CLIENT_ID }}data-clientId="xxxxxx.apps.googleusercontent.com"您的客户端id。您显然已经填写了:CLIENT_IDAPPLICATION_NAME和`client_SECRET in the signin.php`。尝试运行您的应用程序,它应该可以工作。这对我很有效。祝你好运:(