n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
46.4k stars 6.62k forks source link

OAuth2 not working with HTTP Request Tool #11025

Open a-d-r-i-a-n-d opened 2 hours ago

a-d-r-i-a-n-d commented 2 hours ago

Bug Description

Title: OAuth2 from Generic Credentials Type doesn’t work with HTTP Request Tool node but works with HTTP Request node

Description: When using the OAuth2 credentials (specifically Microsoft Graph with grant type client_credentials) in n8n, there is an inconsistency between the HTTP Request Tool node and the HTTP Request node. Although the same credentials are applied to both nodes, the HTTP Request Tool node fails to recognize the credentials, resulting in an error message: “Credentials not found.” However, when using the same OAuth2 credentials in the HTTP Request node, the API call works as expected and returns the correct output.

This appears to be a bug specific to the HTTP Request Tool node’s handling of OAuth2 credentials under the Generic OAuth2 Credential Type.

Screenshot 2024-09-30 at 17 57 41 Screenshot 2024-09-30 at 18 08 52 Screenshot 2024-09-30 at 17 59 55

To Reproduce

  1. Create OAuth2 Credentials: • Go to n8n settings and create a new OAuth2 credential set (e.g., Microsoft Graph). • Set the grant type to client_credentials. • Fill in the appropriate details for client ID, client secret, authorization URL, and token URL.
  2. Test with HTTP Request node: • Add an HTTP Request node. • Configure it to use the newly created OAuth2 credentials. • Set the request URL to an endpoint from Microsoft Graph (e.g., https://graph.microsoft.com/v1.0/me). • Run the workflow. • Expected result: The request works, and you receive the correct response from Microsoft Graph.
  3. Test with HTTP Request Tool node: • Add an HTTP Request Tool node in the same workflow. • Configure the same request, using the same OAuth2 credentials and the same Microsoft Graph API endpoint. • Run the workflow. • Actual result: The request fails, and the error message “Credentials not found” is returned.

Expected behavior

The HTTP Request Tool node should behave in the same way as the HTTP Request node when using OAuth2 credentials, allowing for successful API requests without returning credential-related errors. Both nodes should be able to authenticate and return the correct response from Microsoft Graph when using the same OAuth2 credentials.

Operating System

docker

n8n Version

1.59.4

Node.js Version

v20.17.0

Database

PostgreSQL

Execution mode

main (default)

Joffcom commented 2 hours ago

Hey @a-d-r-i-a-n-d,

We have created an internal ticket to look into this which we will be tracking as "GHC-268"