2

我正在尝试通过 Google Reader 的 OAuth2 获取我的订阅列表。我正在使用 Codeigniter 和一个库 - CI_OPAUTH。我可以毫无问题地获得权限屏幕并授予 Google Reader 权限。问题是当我在身份验证完成后获得回调标头时,它会给我一个 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 天,我不知道我在图书馆的请求中做错了什么。你能帮助我吗?

4

1 回答 1

1

该库尝试获取用户的个人资料,这需要 userinfo.profile 范围(https://www.googleapis.com/auth/userinfo.profile)。将该范围添加到您的配置中,它应该可以工作。

于 2013-08-26T23:52:33.373 回答