Hi everyone,
How do you handle authentication in n8n for APIs such as PlentyONE that use the following flow?
PlentyONE REST API uses OAuth 2.0.
-
Log in by sending a username and password in the JSON request body.
-
Receive
access_token,refresh_token, andexpires_in. -
Use a separate endpoint to renew the access token using the refresh token.
Logging in through an HTTP Request node with a configured credential works. However, I want to avoid logging in and requesting a new token on every workflow execution.
The goal is to log in once and reuse the tokens across multiple executions. A scheduled or manual execution should reuse the existing access token while it is valid. When renewal is necessary, the workflow should use the refresh token. A new login should only be necessary when no valid refresh token is available.
I built the workflow with ChatGPT/Codex. The AI suggested the following approach, which I would like to check against the community’s experience before using it in production:
The username and password are stored in a Custom Auth credential. The access token, refresh token, and expiration time are stored in an n8n Data Table. Valid tokens are reused and refreshed when needed. If the refresh token is invalid, the workflow attempts to log in again automatically.
Personally, storing the tokens in a N8N Data Table does not feel particularly elegant. I expected token management to be handled within the credentials, but I do not have enough experience to judge which approach is standard or recommended.
What is considered best practice for this scenario in n8n? Is managing tokens within the workflow common, or can the entire authentication lifecycle be handled by a credential integration?
I am particularly interested in secure token storage, concurrent executions, and reliable error handling. I cannot find a suitable grant type in the generic OAuth2 credential for the login method described above.
The attached diagram illustrates the proposed approach.
Thanks for sharing your experience!
Environment: n8n Cloud, Starter plan
Version: 2.43.4
Debug info
core
- n8nVersion: 2.43.4
- platform: docker (cloud)
- nodeJsVersion: 26.7.0
- nodeEnv: production
- database: sqlite
- executionMode: regular




