# OAuth2 in GraphQL node not refreshing token

**URL:** <https://community.n8n.io/t/oauth2-in-graphql-node-not-refreshing-token/34248>\
**Category:** Questions\
**Tags:** oauth2\
**Created:** [December 15, 2023, 2:33pm UTC](https://community.n8n.io/t/oauth2-in-graphql-node-not-refreshing-token/34248 "2023-12-15T14:33:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian.O](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/florian.o/32/32005_2.png) [@Florian.O](https://community.n8n.io/u/Florian.O)\
**Post date:** [December 15, 2023, 2:33pm UTC](https://community.n8n.io/t/oauth2-in-graphql-node-not-refreshing-token/34248/1 "2023-12-15T14:33:59Z")

</div>

I’m using the GraphQL node with OAuth2 API credentials but when the token is expired I have to create a new set of credentials in order to have the node working again. Is there any way OAuth token get’s automagically refreshed if it’s expired?

## What is the error message (if any)?

[

{

“extensions”: {

“code”: “UNAUTHENTICATED”

},

“message”: “Invalid OAuth token”

}

]

## Please share your workflow

Workflow only consists of GraphQL node and a manual trigger. Credentials are added to N8N credentials store.

```auto
NodeApiError: Invalid OAuth token
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/GraphQL/GraphQL.node.js:463:27)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:670:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:652:53

```

## Information on your n8n setup

I’m usaing N8N Cloud v1.15.2

After creating a new credential in the credential store in N8N this action works, after an hour when the token is expired it stops working and only creating a new credential fixes the issue, this isn’t acceptable for me, does anyone have a solution for this?

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [December 15, 2023, 2:34pm UTC](https://community.n8n.io/t/oauth2-in-graphql-node-not-refreshing-token/34248/2 "2023-12-15T14:34:01Z")

</div>

It looks like your topic is missing some important information. Could you provide the following if applicable.

- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [December 21, 2023, 3:09pm UTC](https://community.n8n.io/t/oauth2-in-graphql-node-not-refreshing-token/34248/3 "2023-12-21T15:09:48Z")

</div>

> [@Florian.O](#):
>
> After creating a new credential in the credential store in N8N this action works, after an hour when the token is expired it stops working and only creating a new credential fixes the issue, this isn’t acceptable for me, does anyone have a solution for this?

Hi @Florian.O, welcome to the community though I am very sorry you are having trouble.

n8n should refresh OAuth2 tokens in principle, but this has clearly not happened in your case. Is there a chance this could come down to a missing scope or query parameter? Microsoft’s Graph API for example would require an `offline_access`scope to issue a refresh token and allow n8n to refresh the OAuth2 token

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [March 20, 2024, 3:09pm UTC](https://community.n8n.io/t/oauth2-in-graphql-node-not-refreshing-token/34248/4 "2024-03-20T15:09:55Z")

</div>

Closed on March 20, 2024, 3:09pm UTC

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