# Why does refresh\_token disappear after relogin without consent?

**URL:** <https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939>\
**Category:** Get Help\
**Tags:** google-social-connection, connections\
**Created:** [November 15, 2023, 2:28pm UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939 "2023-11-15T14:28:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyox](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dyox/32/32722_2.png) [@dyox](https://community.auth0.com/u/dyox)\
**Post date:** [November 15, 2023, 2:28pm UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/1 "2023-11-15T14:28:53Z")

</div>

Hi,

I am using

> ```
> const url = await buildAuthorizeUrl({
> connection: 'google-oauth2',
> connection_scope:
> 'https://www.googleapis.com/auth/calendar.readonly',
> access_type: 'offline',
> prompt: 'consent',
> });
> 
> ```

in order to login an user and have an access\_token / refresh\_token to be able to use Google Calendar API later on. It works perfectly.

Since the user already gave the consent at the first login, I would like to avoid showing consent all the time when the user needs to login again.

The refresh\_token disappear from “google-oauth2” provide identity when I do so.  
Is it an expected behavior? How can I achieve a non consent following logins when the consent was already given by the user?

Thanks.

---

<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:** [November 17, 2023, 4:06pm UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/3 "2023-11-17T16:06:14Z")

</div>

Hi @dyox,

Welcome to the Auth0 Community!

I understand you are having issues with retrieving Google refresh tokens.

Before we go any further, is there a reason you are using the legacy SDK auth0.js? You may be better off using the newer [auth0-spa-js sdk](https://github.com/auth0/auth0-spa-js). From the code sample you provided, you should be able to have the same behavior with a more secure flow.

---

<div class="post-metadata">

**Author:** ![dyox](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dyox/32/32722_2.png) [@dyox](https://community.auth0.com/u/dyox)\
**Post date:** [November 20, 2023, 12:52am UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/4 "2023-11-20T00:52:34Z")

</div>

Hi @dan.woda ,

I followed this tutorial [Auth0 Ionic & Capacitor (React) SDK Quickstarts: Add login to your Ionic React with Capacitor app](https://auth0.com/docs/quickstart/native/ionic-react/interactive) and it prompted me to install `@auth0/auth0-react`.  
I think I was searching for a way to pass `connection_scope`, `access_type: 'offline'` and `prompt: 'consent'` in order to get the `refresh_token` from Google, I found `buildAuthorizeUrl` somewhere in the documentation or forum (?).

I am open to any kind of improvement.

---

<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:** [November 20, 2023, 3:08pm UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/5 "2023-11-20T15:08:17Z")

</div>

It looks like this behavior is intended by Google:

> <https://github.com/googleapis/google-api-php-client/issues/1686>
>
> Hi Team,
> 
> How can we get refresh a token with out using consent screen.
> 
> My …case here. 
> We have prompt=consent initially and we got refresh token every time and consent screen displays every time. Now we want to change prompt = select\_account so that consent screen wont appears again and again. But if change we are missing \*refresh token\* which we need to process further. Earlier we didn't saved refresh token for users, now if we change prompt=select\_account we are not getting \*refresh token\* once user logged in.
> 
> I've tried prompt="consent"/ "select\_account"/ "none"
> 
> Please suggest us way to achieve this to remove consent screen again and again for users and also to get refresh token with out affecting the already logged in users. 
> 
> Earliest reply more help full for us.
> 
> Thanks.

So you will need to fetch the refresh token from Auth0 and store it after the first successful login.

---

<div class="post-metadata">

**Author:** ![dyox](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dyox/32/32722_2.png) [@dyox](https://community.auth0.com/u/dyox)\
**Post date:** [November 21, 2023, 1:05am UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/6 "2023-11-21T01:05:46Z")

</div>

@dan.woda Thanks for your answer.

I was aware of this behavior but since the `refresh_token` was already stored in Auth0 (at the first login and consent), I thought there was a way to keep it in Auth0. I didn’t want to store it in my Database but it seems like that’s the only solution.

---

<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:** [November 21, 2023, 1:35pm UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/7 "2023-11-21T13:35:44Z")

</div>

I tested it and can confirm this is the behavior I am seeing.

If you’d like, you can leave us some feedback here: #Feedback.

---

<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:** [December 5, 2023, 1:36pm UTC](https://community.auth0.com/t/why-does-refresh-token-disappear-after-relogin-without-consent/120939/8 "2023-12-05T13:36:30Z")

</div>

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