OAuth2 Options and Troubleshooting

This is the CURL connection for my Oauth request.

curl --request POST
–url https://token-manager.XXXX.com/oauth/token
–header ‘content-type: application/json’
–data ‘{“client_id”:“”,“client_secret”:“”,“audience”:“api://XXXX.client”,“grant_type”:“client_credentials”}’

I don’t see a way to add audience or grant_type to the body when using the grant type “Client Credentials”.

I’m getting an HTTP CODE EAUTH error, but there isn’t anything about the authorization in the console so I’m not sure how to troubleshoot this.

Hey @j0dan,

The grant type is set based on if you select Client Credentials or Authorization Code so that should be ok, The only that may be an issue is the audience which I assume is the client version of a scope.

At the moment we don’t have an option for this but I will get a feature request created so that we can allow more changes in a future release.

Out of interest what is the API you are connecting to?

Pax8, a distributor of SaaS licensing.

Any update on this?

Hey @j0dan,

Nothing yet as this doesn’t appear to be a common case. Do Pax8 have public api docs?

@Jon @j0dan
We are using Auth0, a huge provider, and there the audience is also required so we are not able to authenticate. Is this still debated? Otherwise I would open a pull request to get this minor issue sorted out.

Hey @Chrissi_Grilus,

Welcome to the community :raised_hands:

Is that to use the Auth0 API or is that for the Auth0 Authentication API which from my understanding is used to authenticate against a custom app using Auth0 rather than to use Auth0?

Any update on this problem? I am also trying to connect to Pax8

Create a new Access Token

I’m also stuck on the same thing, it’s the only thing I need to finish my project. The problem is that when you use n8n for a company, they don’t let you have the client id and secret of auth0 for security, so I can’t use a simple http request. So what I need is to be able to send the audience in the oauth2 api credential, and thus the n8n administrator can create the credential and I can use it, but it fails because it does not have the audience field. @Jon Could you please help us prioritize this? because if it is not possible we will have to stop using n8n in my company.

Hello guys, I found the way to set these other fields like audience in a auth token and use it in the HTTP Request node.

You have to create a Custom Auth credential following this documentation.

It depends if you have to pass those fields by the headers, body or query string. In my case I have to pass them by the body to retrieve the Auth0 access token. So, in my case I configure my Custom Auth credential something like this:

{
  "body": {
    "client_id": "UJij0xoxxxxxxxxxxxxxxxx",
    "client_secret": "ZLpJ3Mxxxxxxxxxxxxxxxxxxxxx",
    "audience": "https://domain-test.com",
    "grant_type": "client_credentials"
  }
}

And then use this credential directly in my HTTP Request node with Authentication → Generic Credential type → Custom Auth (and select your credential).

I hope this helps you create more customizable credentials!

FYI @j0dan @Jon

I’ve created an PR which was just merged in that solves this issue. We should hopefully see it in the next release.

Basically, when setting up OAuth2 with Client Credentials, you’ll now be able to add ‘additional body properties’ that would you like to send with the token request such as audience or grant_type.

Hope this enables a lot of people to be able to utilize these third party APIs in n8n that require it!

New version n8n@1.107.0 got released which includes the GitHub PR 16573.

Got this to work with Pax8 using the Additional Body Parameters using OAuth2 API Client Credentials.