一小时后FOSOAuthServerBundle + HWIOAuthBundle超时401

时间:2013-07-30 01:51:55

标签: oauth-2.0 bundle http-status-code-401 symfony-2.3 hwioauthbundle

我是用户HWIOAuthBundle(我们称之为MyClient),使用FOSOAuthServerBundle连接到Symfony 2.3.2 OAuth 2服务器(我们称之为MyServer)。我能够连接并登录并执行我需要的请求但是我在一小时后继续从“MyServer”启动(401错误)。我已经做了很多关于这个问题的阅读,但似乎无法找到解决方案。

我是OAuth的新手,但我相信我使用的access_token会在一小时后过期。

我想知道是否有办法配置两台计算机使用刷新令牌(在2年后到期),以便在到期后“刷新”我的access_token?

我一直无法找到如何做到这一点的例子。任何帮助都会很棒。

干杯

1 个答案:

答案 0 :(得分:1)

我遇到了与使用Google登录进行身份验证的HWIOAuthBundle相同的问题。最后我找到了如何请求离线访问。在config.yml中,将选项access_type设置为offline

hwi_oauth:
    firewall_name: main
    fosub:
        properties:
            google: googleId
    connect:
        account_connector: acme.security.provider.user
    resource_owners:
        google:
            type:                  google
            client_id:            <my_id>
            client_secret:     <my_secret>
            scope:               "https://www.googleapis.com/auth/userinfo.email    https://www.googleapis.com/auth/userinfo.profile     https://www.googleapis.com/auth/analytics.readonly"
            options:
                access_type:     offline

查看更多https://github.com/hwi/HWIOAuthBundle/issues/375