# Issue with obtaining a refresh token using Lock and social connection

**URL:** <https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677>\
**Category:** Get Help\
**Tags:** refresh-tokens, social-connections\
**Created:** [November 6, 2017, 9:47pm UTC](https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677 "2017-11-06T21:47:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayesh.ce](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jayesh.ce/32/12805_2.png) [@jayesh.ce](https://community.auth0.com/u/jayesh.ce)\
**Post date:** [November 6, 2017, 9:47pm UTC](https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677/1 "2017-11-06T21:47:28Z")

</div>

I have followed the guide from [https://auth0.com/docs/connections/social/fitbit](https://auth0.com/docs/connections/social/fitbit) to get user authenticated using fitbit.

I am using latest version of auth0 lock and here is my options passed to lock:

```
static AUTH0_LOCK_OPTIONS = {
      auth: {
        audience: 'http://api.mydomain.com/api/v2',
        redirect: true,
        responseType: 'code', // also tried token
        params: {
          scope: 'openid offline_access email user_metadata app_metadata picture'
        },
        sso: false
      },
      oidcConformant: true,
      allowAutocomplete: true,
      rememberLastLogin: true,
      allowedConnections: 'Username-Password-Authentication']
    };

```

Here is the auth0 result I get back WITOUT REFRESH TOKEN

```
{  
   "accessToken":"eyJ....",
   "idToken":null,
   "idTokenPayload":null,
   "appStatus":null,
   "refreshToken":null,
   "state":"mK11...",
   "expiresIn":7200,
   "tokenType":"Bearer",
   "scope":"openid email"
}

```

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [November 6, 2017, 11:15pm UTC](https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677/2 "2017-11-06T23:15:00Z")

</div>

The use of Lock with response type `code` implies that the tokens that were requested will be provided after performing an authorization code exchange at the token endpoint. In summary, the refresh token if one would be issued would never be available to Lock which running client-side in the browser.

In addition, the refresh token will only be issued if the API associated with the provided `audience` allows refresh tokens to be issued (aka allows offline access).

If you try with response type `token` then the authorization endpoint will immediately provide you with the tokens (aka implicit grant) and you don’t have to perform an additional exchange at the token endpoint. **However, with an OIDC-compliant implicit grant** , given the tokens are returned and visible to the client-side part of the web application, **the issuance of refresh tokens is not supported**.

In conclusion, if you have a server-side web application you should use `code` and the server-side should exchange the code for the tokens; if you have a SPA you should use `token` (implicit grant) and when the initial token expires try to obtain a new one using [silent authentication](https://auth0.com/docs/api-auth/tutorials/silent-authentication).

---

<div class="post-metadata">

**Author:** ![jayesh.ce](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jayesh.ce/32/12805_2.png) [@jayesh.ce](https://community.auth0.com/u/jayesh.ce)\
**Post date:** [November 7, 2017, 5:23pm UTC](https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677/3 "2017-11-07T17:23:10Z")

</div>

@jmangelo thanks for your prompt reply. I know it is little different than what I asked originally but I have a mobile app built using Ionic and user can choose to sync data from fitbit. User has ability to sync manually or there will be a windows service syncing data over night. I am not sure what can I do to authenticate user when windows service running is over night? My Backend is WebAPI and windows services to fetch user data

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [November 7, 2017, 10:20pm UTC](https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677/4 "2017-11-07T22:20:38Z")

</div>

What you now describe implies that you would need a refresh token and access token for the Fitbit API itself. Have in mind that the tokens resulting from an authentication flow that was processed through Auth0 are tokens associated with Auth0 itself and not the underlying social provider. You can still obtain the underlying provider tokens through this [process](https://auth0.com/docs/tokens/idp), but that process only supports obtaining refresh tokens for some for some of the providers and Fitbit is not one of them.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:57am UTC](https://community.auth0.com/t/issue-with-obtaining-a-refresh-token-using-lock-and-social-connection/8677/5 "2018-03-02T05:57:18Z")

</div>


