# 401 Error on Multiple Pod Saves

**URL:** <https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870>\
**Category:** General Discussion\
**Created:** [November 22, 2022, 9:56pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870 "2022-11-22T21:56:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaz009](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gaz009](https://forum.solidproject.org/u/gaz009)\
**Post date:** [November 22, 2022, 9:56pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/1 "2022-11-22T21:56:53Z")

</div>

Hello All,

I have a data stream that ingests data then saves the new data every 10 seconds to a specific resource. This seems to work until a certain point at which all saves and gets to the resource return a 401 error until I kill the process and restart it. The server is ESS. Does anyone have an idea about this?

Thanks

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [November 23, 2022, 3:00am UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/2 "2022-11-23T03:00:36Z")

</div>

401 like this would absolutely imply your session has expired, you’d have to share some code. If you’re using `@inrupt/solid-client-authn-node`, then periodically the session will emit an event refresh token event, and then the session needs to be updated, it’s kind of documented here: [Authenticate (Node.js: Single-User App) — Inrupt JavaScript Client Libraries](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/authenticate-nodejs-script/#authenticate-with-a-refresh-token)

But, if your script is only updating periodically, creating a session when you do the update, rather than holding the session open may be better.

---

<div class="post-metadata">

**Author:** ![gaz009](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gaz009](https://forum.solidproject.org/u/gaz009)\
**Post date:** [November 23, 2022, 5:11pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/3 "2022-11-23T17:11:08Z")

</div>

Thanks for the response.

I see what you mean - however how do I retrieve the initial refresh token in nodejs using the Inrupt libraries? I didn’t see an example for it unless I missed it.

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [November 24, 2022, 1:51am UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/4 "2022-11-24T01:51:40Z")

</div>

It’s emitted by an event, it is in the docs; but it all depends on what your code looks like

---

<div class="post-metadata">

**Author:** ![gaz009](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gaz009](https://forum.solidproject.org/u/gaz009)\
**Post date:** [November 28, 2022, 8:35pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/5 "2022-11-28T20:35:52Z")

</div>

I see. I believe I am using static access as there is no mention or instance of a refresh token for authorization. After some number of saves or time, my next save is met with a 401 Unauthorized error. Is there a time/push limit for static access?

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [November 28, 2022, 9:04pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/6 "2022-11-28T21:04:17Z")

</div>

Even with static client credentials, you still get a time bound access token and refresh token, and sometimes an ID token, you can see this in the code here: [solid-client-authn-js/ClientCredentialsOidcHandler.ts at main · inrupt/solid-client-authn-js · GitHub](https://github.com/inrupt/solid-client-authn-js/blob/main/packages/node/src/login/oidc/oidcHandlers/ClientCredentialsOidcHandler.ts)

---

<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 28, 2022, 9:19pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/7 "2022-11-28T21:19:48Z")

</div>

Am I correct that if one logs in with a provider whose access token is longer, one can can use that instead? For example, if, on my ESS pod, I give all rights to my [solidcommunity.net](http://solidcommunity.net) WebID and then login at [solidcommunity.net](http://solidcommunity.net), I will have a longer timeout when visiting ESS?

[EDIT] … or would the longer timeout only apply to the user, but not to the app?

---

<div class="post-metadata">

**Author:** ![gaz009](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gaz009](https://forum.solidproject.org/u/gaz009)\
**Post date:** [November 28, 2022, 9:56pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/8 "2022-11-28T21:56:16Z")

</div>

Thank you. Is there perhaps a code sample in js/ts to get the initial refresh token? I understand the onNewRefreshToken callback, but retrieving the initial refresh token was not demonstrated to my knowledge.

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [November 28, 2022, 10:59pm UTC](https://forum.solidproject.org/t/401-error-on-multiple-pod-saves/5870/9 "2022-11-28T22:59:54Z")

</div>

That’d depend on the identity provider of the authenticated user, and also on the pod storage provider, I think. But mostly the former.
