我正在为我的网站创建一个谷歌登录名,以便直接从他们的谷歌帐户注册用户。我http://www.sanwebe.com/2012/11/login-with-google-api-php
遵循了本教程,并且能够访问所需的信息。但是在请求许可页面上,它说该网站希望有offline access
。
我如何显示它以声明我想访问电子邮件和基本个人资料信息。
客户端创建代码如下:
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("email");
$client->addScope("profile");
使用以下
代码添加作用域:
$client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/moderator'));
这将起作用。
addScope("https://www.googleapis.com/auth/plus.loginhttps://www.googleapis.com/auth/userinfo.email");