使用OAuth2的Google阅读器订阅

时间:2013-06-13 12:35:09

标签: php codeigniter oauth google-oauth

我正试图通过来自Google阅读器的OAuth2获取我的订阅列表。 我正在使用Codeigniter和library - CI_OPAUTH。我可以获得权限scren没有问题,并授予谷歌阅读器权限。问题是当我在完成身份验证后获得回调标头时,它会给我一个403 Forbidden标头。

以下是我对图书馆的选择:

    $config['opauth_config'] = array(
    'path' => '/mixordia/index.php/oauth/login/', //example: /ci_opauth/auth/login/
    'callback_url' => '/mixordia/index.php/oauth/authenticate/', //example: /ci_opauth/auth/authenticate/
    'callback_transport' => 'get', //Codeigniter don't use native session
    'security_salt' => 'mixordias_salt_whwhwh_wayacross',
    'debug' => true,
    'Strategy' => array(
        'Google' => array(
            'client_id' => 'MY_ID',
            'client_secret' => 'MY_SECRET',
            'service' => 'reader',
            'source' => 'APP Name',
            'scope' => 'http://www.google.com/reader/api'
        )
    )
);

这是我得到的:

Array
(
[error] => Array
    (
        [provider] => Google
        [code] => userinfo_error
        [message] => Failed when attempting to query for user information
        [raw] => Array
            (
                [response] => 0
                [headers] => HTTP/1.0 403 Forbidden
WWW-Authenticate: Bearer realm="https://www.google.com/accounts/AuthSubRequest",     error=insufficient_scope, scope="https://www.googleapis.com/auth/userinfo.id h ttps://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.login https://www.google.com/accounts/OAuthLogin"
Content-Type: application/json; charset=UTF-8
Date: Thu, 13 Jun 2013 12:26:25 GMT
Expires: Thu, 13 Jun 2013 12:26:25 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
            )

    )

[timestamp] => 2013-06-13T12:26:25+00:00
)

我已经坚持了2天,我不知道我在图书馆的请求中做错了什么。你能救我吗?

1 个答案:

答案 0 :(得分:1)

库尝试get user's profile,这需要userinfo.profile范围(https://www.googleapis.com/auth/userinfo.profile)。将该范围添加到您的配置中它应该可以正常工作。

相关问题