Php 401 oauth 2.0 google+api的凭据无效,引发apiServiceException..为什么。。?

Php 401 oauth 2.0 google+api的凭据无效,引发apiServiceException..为什么。。?,php,oauth-2.0,google-plus,Php,Oauth 2.0,Google Plus,这是我如何编码,以获得谷歌认证用户和显示基本的东西 使用google对用户进行身份验证时出错 错误:oauth 2.0 google+api的凭据无效,引发apiServiceException 这是我的代码: <?php require_once 'google-api-php-client/src/apiClient.php'; require_once 'google-api-php-client/src/contrib/apiPlusService.php'; require_on

这是我如何编码,以获得谷歌认证用户和显示基本的东西

使用google对用户进行身份验证时出错

错误:oauth 2.0 google+api的凭据无效,引发apiServiceException

这是我的代码:

<?php
require_once 'google-api-php-client/src/apiClient.php';
require_once 'google-api-php-client/src/contrib/apiPlusService.php';
require_once 'google-api-php-client/src/contrib/apiOauth2Service.php';

session_start();

$client = new apiClient();

$client->setApplicationName('demo');
$client->setClientId('asd6354egfdgtdewd');
$client->setClientSecret('-ooRVhB5nbdsfisfgf7s6fsfsfj');
$client->setRedirectUri('http://demo.com');
$client->setDeveloperKey('HGFHJVhjb894rbbvjhdfjdsvkbdvdv');

$client->setScopes(array('https://www.googleapis.com/auth/plus.me',
                             'https://www.googleapis.com/auth/userinfo.email'));

$plus   = new apiPlusService($client);
$oauth2 = new apiOauth2Service($client);

if (isset($_REQUEST['logout']))
{
    unset($_SESSION['access_token']);
}

if (isset($_GET['code']))
{
    $client->authenticate();
    $_SESSION['access_token'] = $client->getAccessToken();
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
            # FIXME Is exit() missing?
}

if (isset($_SESSION['access_token']))
{
    $client->setAccessToken($_SESSION['access_token']);
}

if ($client->getAccessToken())
{
        $me   = $plus->people->get('me');
        $user = $oauth2->userinfo->get();

            $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);

            $optParams = array('maxResults' => 100);
        $activities = $plus->activities->listActivities('me', 'public',$optParams);

        $_SESSION['access_token'] = $client->getAccessToken();

    } else {

           $authUrl = $client->createAuthUrl();

}

在调用$plus->people->get'me和$user=$oauth2->userinfo->get之前,您必须先调用函数setAccessToken$token。

您能在oauth的谷歌游乐场中测试所有配置吗。。。请你指导我在oauth操场进行测试好吗?第二步怎么办?其实很简单。只需从左侧选择您想要使用的服务,并点击prace Authorization app按钮,然后点击wizrd按钮……但在referesh token和access token中写什么呢????code.google.com/p/oauth-plugin/wiki/RequestToken