# Unable to obtain refresh token from social login with native API

**URL:** <https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118>\
**Category:** Get Help\
**Tags:** login, auth0\
**Created:** [June 8, 2021, 6:00pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118 "2021-06-08T18:00:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenneth](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenneth/32/29879_2.png) [@kenneth](https://community.auth0.com/u/kenneth)\
**Post date:** [June 8, 2021, 6:00pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/1 "2021-06-08T18:00:34Z")

</div>

I am unable to obtain refresh token after logging in via social connections, even if `offline_access` scope is included. The `refresh_token` grant type is enabled in application settings. I am having this issue with both the Android SDK and the iOS SDK.

A snippet of the code I am using to trigger social login:

```kotlin
WebAuthProvider.login(account)
            .withScope("openid profile email offline_access")
            .withConnection("google-oauth2")
            .withAudience("myaudience")
            .start(context, callback)

```

Any help is much appreciated!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 8, 2021, 8:20pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/2 "2021-06-08T20:20:43Z")

</div>

Hi @kenneth,

Welcome to the Community!

Have you enabled refresh tokens (offline access) in your API settings?

---

<div class="post-metadata">

**Author:** ![kenneth](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenneth/32/29879_2.png) [@kenneth](https://community.auth0.com/u/kenneth)\
**Post date:** [June 8, 2021, 8:58pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/3 "2021-06-08T20:58:12Z")

</div>

Hello Dan, the only API i have is the management API which I cannot change. I don’t need to call any API actually, I just need the access token and refresh token for authentication purpose.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 8, 2021, 9:18pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/4 "2021-06-08T21:18:09Z")

</div>

Thanks for the added info. It may be because you are sending an audience param with your request. You can omit that param if you aren’t requesting an access token for an API.

---

<div class="post-metadata">

**Author:** ![kenneth](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenneth/32/29879_2.png) [@kenneth](https://community.auth0.com/u/kenneth)\
**Post date:** [June 8, 2021, 9:32pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/5 "2021-06-08T21:32:35Z")

</div>

I tried doing that and it still wouldn’t return a refresh token (and an id token for that matter), it seems like it’s doing an implicit flow because when i tried to exclude `implicit_flow` from the list of grant types i get an error page indicating that `implicit_flow` isn’t enabled, even though afaik both native SDKs use PKCE flow. i know that using implicit grant i will not receive a refresh token, but i can’t figure out a way to use PKCE instead of implicit grant.

---

<div class="post-metadata">

**Author:** ![kenneth](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenneth/32/29879_2.png) [@kenneth](https://community.auth0.com/u/kenneth)\
**Post date:** [June 9, 2021, 1:23pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/6 "2021-06-09T13:23:31Z")

</div>

Any help from anyone? I still cannot figure out what the issue is.

---

<div class="post-metadata">

**Author:** ![kenneth](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenneth/32/29879_2.png) [@kenneth](https://community.auth0.com/u/kenneth)\
**Post date:** [June 9, 2021, 1:47pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/7 "2021-06-09T13:47:56Z")

</div>

It’s finally working on Android for some reason, but it’s still not working on iOS.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 9, 2021, 3:42pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/8 "2021-06-09T15:42:27Z")

</div>

> [@kenneth](#):
>
> it seems like it’s doing an implicit flow because when i tried to exclude `implicit_flow` from the list of grant types i get an error page indicating that `implicit_flow` isn’t enabled

It shouldn’t be using the implicit flow.

Can you post a code snippet of your Auth0 iOS implementation?

---

<div class="post-metadata">

**Author:** ![kenneth](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenneth/32/29879_2.png) [@kenneth](https://community.auth0.com/u/kenneth)\
**Post date:** [June 9, 2021, 3:51pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/9 "2021-06-09T15:51:37Z")

</div>

Actually, after some more tweaking, I managed to get it working:

```swift
Auth0
      .webAuth()
      .scope("openid email profile offline_access")
      .connection("google-oauth2")
      .start()

```

It is probably because of the audience parameter that i originally put in. Thank you dan!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 9, 2021, 3:52pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/10 "2021-06-09T15:52:35Z")

</div>

Great news! Thanks for posting an update. Let us know if you run into anything else.

---

<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:** [June 24, 2021, 3:52pm UTC](https://community.auth0.com/t/unable-to-obtain-refresh-token-from-social-login-with-native-api/64118/11 "2021-06-24T15:52:42Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
