# Refresh Token with generate-oidc-token tool

**URL:** <https://forum.solidproject.org/t/refresh-token-with-generate-oidc-token-tool/4837>\
**Category:** General Discussion\
**Created:** [November 4, 2021, 6:05pm UTC](https://forum.solidproject.org/t/refresh-token-with-generate-oidc-token-tool/4837 "2021-11-04T18:05:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincenzo-dip8](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/vincenzo-dip8/32/2985_2.png) [@vincenzo-dip8](https://forum.solidproject.org/u/vincenzo-dip8)\
**Post date:** [November 4, 2021, 6:05pm UTC](https://forum.solidproject.org/t/refresh-token-with-generate-oidc-token-tool/4837/1 "2021-11-04T18:05:25Z")

</div>

I can’t understand the mechanism of generating a new token after logging. What is specified as _“Handling refresh token rotation”_ . In particular, known that, once you have obtained the token through the **generate-oidc-token** tool, this **“expires” immediately after its (first and only) use**. I believed that “Expiration Date” refer to the general duration of the token, and not at the expiry of the same.  
**Where am I wrong to reason?**  
In any case, the explanation of the mechanism cites:

> "…each time the client application uses a Refresh Token to get a new Access Token, **a new Refresh Token is also returned**. The previous Refresh Token is invalidated, and can no longer be used to get Access Tokens.
> 
> `@inrupt/solid-client-authn-node` has an internal mechanism to manage refresh tokens in the Session’s storage. For the Session’s storage, you can pass in a [storage](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/interfaces/ISessionOptions.html#storage) as an [option](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/interfaces/ISessionOptions.html) to the [Session constructor](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/classes/Session.html#constructor) or use the default storage, which is an in-memory storage. If you pass in a persistent storage, the refresh token management is transparent. However, for NodeJS scripts that use the Session’s default in-memory storage, the storage (and hence the refresh token) **is lost when the program stops.**
> 
> As an alternative to providing a [persistent storage](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/interfaces/ISessionOptions.html#storage) to the [Session constructor](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/classes/Session.html#constructor), you can pass in the [onNewRefreshToken](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/interfaces/ISessionOptions.html#onnewrefreshtoken) callback to the constructor **instead**. Then, each time a new refresh token is issued, the [onNewRefreshToken](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/interfaces/ISessionOptions.html#onnewrefreshtoken) callback is invoked with the new refresh token as a parameter. The [onNewRefreshToken](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-node/interfaces/ISessionOptions.html#onnewrefreshtoken) option allows you to run custom code to handle the refresh token as appropriate.

I tried the use of onNewRefreshToken, but I couldn’t get anything and I’m still forced to use the tool for every time I have to test my code to log in.  
**Do you have usage suggestions ??**

---

<div class="post-metadata">

**Author:** ![jeffz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeffz/32/600_2.png) [@jeffz](https://forum.solidproject.org/u/jeffz)\
**Post date:** [November 4, 2021, 6:35pm UTC](https://forum.solidproject.org/t/refresh-token-with-generate-oidc-token-tool/4837/2 "2021-11-04T18:35:27Z")

</div>

1. get a pod on some other server like [solidcommunity.net](http://solidcommunity.net) 2) on your [Inrupt.com](http://Inrupt.com) pod, give permission to your [solidcoummunity.net](http://solidcoummunity.net) WebID 3) login to [solidcommunity.net](http://solidcommunity.net) 4) use that login to visit [Inrupt.com](http://Inrupt.com).

---

<div class="post-metadata">

**Author:** ![vincenzo-dip8](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/vincenzo-dip8/32/2985_2.png) [@vincenzo-dip8](https://forum.solidproject.org/u/vincenzo-dip8)\
**Post date:** [November 5, 2021, 10:44am UTC](https://forum.solidproject.org/t/refresh-token-with-generate-oidc-token-tool/4837/3 "2021-11-05T10:44:25Z")

</div>

i ll try asap.

meantime can you tell me why this should be a solution? Why using [solidcommunity.net](http://solidcommunity.net) could be the remedy?  
I will always use the tool generate-oidc-token

PS: on the yesterday Solid meeting i d like to ask some stuff but Marelle saw that the time was finished.

---

<div class="post-metadata">

**Author:** ![jeffz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeffz/32/600_2.png) [@jeffz](https://forum.solidproject.org/u/jeffz)\
**Post date:** [November 5, 2021, 2:02pm UTC](https://forum.solidproject.org/t/refresh-token-with-generate-oidc-token-tool/4837/4 "2021-11-05T14:02:12Z")

</div>

Each server uses a different token time out strategy. [Inrupt.com](http://Inrupt.com) uses the ESS server which has a very short time out for security reasons. [Solidcommunity.net](http://Solidcommunity.net) uses NSS which has a longer token though it may sometime shorten it.

Solid World is for presenting new information about Solid, not for troubleshooting app-development issues. This forum and the chat rooms are the best place for that. Many of your questions relate to Inrupt products and that best place to address those is at Inrupt’s help desk.
