# I cannot refresh a token with a public client

**URL:** <https://forum.keycloak.org/t/i-cannot-refresh-a-token-with-a-public-client/10574>\
**Category:** Miscellanaeous\
**Created:** [August 17, 2021, 1:53pm UTC](https://forum.keycloak.org/t/i-cannot-refresh-a-token-with-a-public-client/10574 "2021-08-17T13:53:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oedam](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oedam](https://forum.keycloak.org/u/oedam)\
**Post date:** [August 17, 2021, 1:53pm UTC](https://forum.keycloak.org/t/i-cannot-refresh-a-token-with-a-public-client/10574/1 "2021-08-17T13:53:47Z")

</div>

I am trying to refresh an access token:

```auto
const url = "http://localhost/auth/realms/myrealm/protocol/openid-connect/token"
const params = new URLSearchParams();
params.append('grant_type', 'refresh_token');
params.append('client_id', "web");
params.append('refresh_token', "eyJhbGci...");

const config = {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  },
};
require('axios').post(url, params, config).then(resp => {
  console.log(resp.data)
}).catch(e => {
  console.log(e.response.data)
  console.log(e.response.status)
})

```

This output the following error:

```auto
{ error: 'invalid_grant', error_description: 'Token is not active' }

```

This is my client configuration:

[![enter image description here](https://i.stack.imgur.com/5g6Ko.png)](https://i.stack.imgur.com/5g6Ko.png)

For what is worth the same happens with curl

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [August 17, 2021, 4:58pm UTC](https://forum.keycloak.org/t/i-cannot-refresh-a-token-with-a-public-client/10574/2 "2021-08-17T16:58:06Z")

</div>

That looks correct. Did you happen to restart keycloak in between getting the refresh token and trying to refresh?

---

<div class="post-metadata">

**Author:** ![oedam](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oedam](https://forum.keycloak.org/u/oedam)\
**Post date:** [August 18, 2021, 2:33am UTC](https://forum.keycloak.org/t/i-cannot-refresh-a-token-with-a-public-client/10574/3 "2021-08-18T02:33:12Z")

</div>

I think I have underestimated the duration of the refresh token, it was basically expired, thanks.
