4

I'm user HWIOAuthBundle (let's call it MyClient) to connect to a Symfony 2.3.2 OAuth 2 server using FOSOAuthServerBundle (let's call it MyServer). I am able to connect and login and do the requests that I need to but I keep getting booted out of "MyServer" after an hour (401 error). I have done a lot of reading about this issue but can't seem to find a solution.

I'm new to OAuth but I believe that the access_token I'm using expires after an hour.

I was wondering if there is a way to configure both machines to use the refresh token (which expires in 2 years) to "refresh" my access_token when it expires?

I have been unable to find an example on how to do this. Any help would be great.

Cheers

j0k
  • 22,600
  • 28
  • 79
  • 90

1 Answers1

1

I had the same problem with HWIOAuthBundle to authenticate using Google Login. Finally I found how to request offline access. In config.yml set the option access_type to 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

See more https://github.com/hwi/HWIOAuthBundle/issues/375