N8n OAuth2 (Client Credentials) credential not sending Bearer token in HTTP Reques

Describe the problem/error/question

I’m trying to use n8n’s built-in OAuth2 credential (Grant Type: Client Credentials) with an HTTP Request node, but the API call appears to be sent without the Authorization: Bearer <access_token> header. I’m not sure how to confirm whether n8n is successfully fetching the token via the credential handler, or why the token isn’t being attached to the request.

What is the error message (if any)?

The request to the protected API endpoint returns an authentication/authorization failure (401/403). In the HTTP Request node’s execution details, I don’t see an authorization header being sent.

Please share your workflow

Information on your n8n setup

You’ll need to make sure the HTTP Request node is configured to use the OAuth2 credential correctly. Check the HTTP Request node’s settings to ensure the “Authentication” field is set to your OAuth2 credential. Also, in the “Headers” section, confirm that you haven’t accidentally overridden the Authorization header.

If that doesn’t work, verify that the OAuth2 credential itself is configured with the correct token URL and scopes. Sometimes a misconfiguration there can prevent the token from being retrieved properly.

I’ve tested it a bunch of different ways.

I can get the token and make the call just fine in postman. I’ll double check everything again. When I go to the developer console the bearer token isn’t in the call to the api.

Is there a way to see the response the credential manager got from the oauth2/token call?

If you open your console i browser you can see the raw requests being made and exchanged.

Hi @Jorge_Fernandez

How is you Oauth2 credentials set up? You have the option to send it in body and header:

Most API’s will use header

1 Like

this api seems to want body per the documentation but when testing in postman it accepts it either way. I’ve tried it both through here. I’ve also check the developer console logs and it never passes the Bearer token in the header in the POST request.

Alright, is your grant type set as client credential?

1 Like

Yes its set as client credential

I had this problem with an API i was working on. I couldnt get any response so i made a custom request for the token.
In my workflow i have two request, one to get the token and the other to call the URL

The HTTP Request Node of the Token has:

Method POST

URL www.example.com/auth/realms/pci/protocol/openid-connect/token

Authentication Generic Credential Type

Generic Auth Type Basic Auth

Basic Auth MyCredentials

Send Body True

Body Content Type Form UrlEncoded

Specify Body Using Fields Below

  • Name grant_type
  • Value client_credentials

MyCredentials contains

  • User your_client_id
  • Password your_client_secret

After this, I do the fetch and the return is in my case a json with the access token, there is also expiration and an empty key of refresh_token, so i guess is never used it

I hope this helps, if you have any questions or issues just say it and we can work around