Generic OAuth2 usage

Describe the problem/error/question

I’m attempting to create a new flow using generic oauth2 credentials to make an API call. I’m confused around whether I need to have an explicit authentication HTTP call to get the authorization token, or whether n8n will take care of that step automatically as defined in the generic credentials. From what I’ve read and the testing that I’ve done, it seems that I need to make the explicit authentication call 1st to get the token and then use that token in subsequent HTTP requests. Can someone confirm if this is correct?

Information on your n8n setup

  • n8n version: 1.95.3
  • Database (default: SQLite): n/a
  • n8n EXECUTIONS_PROCESS setting (default: own, main): n/a
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: n/a

n8n will handle it for you. You don’t need to make the initial request to get the refresh token.

When activating the credential, it will call the request api and have you authenticate, then when you’re redirected back to the redirect URI (in n8n) it will grab the refresh token and manage it for you.

There are some instances where i have seen this not work, like in some Zoho apps for instance, and in those cases i sometimes handle the oauth logic manually like i show here

1 Like

Hi Liam,

Appreciate the info here. So would the following flow make sense:

  • Generic OAuth2 credentials are added in n8n including access token URL, credentials, scopes etc.
  • In a workflow, an explicit HTTP requiest to retrieve the authentication token is not required, I just need to add the link to the credentials in the authentication section of the HTTP request
    ** If so, how does this HTTP request know how to use the retrieved token?

Yes the built in oauth creds do everything for you after creating it.

It uses logic in the background to see if it needs to refresh the token and does it automatically, you don’t need to think about it, it just happens in the background

Got it thanks. I’m attempting to do that with HTTP request notes but I’m getting a 403 saying that the authentication has failed and having troubleshooting, any suggestions?

Never mind! I was fat fingering it, found the root cause (me!).

Great, glad to hear you got it working

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