Microsoft Graph connection with Oauth2

Hello everyone I would like to use Microsoft Graph API, but i really don’t understand how to connect my microsoft Azure.
I’ve followed lot of documentation, but maybe I made some confusion.
The topic are:

https://www.integromat.com/en/help/calling-microsoft-graph-rest-api-via-the-http-make-a-oauth-2-0-request-module

I think that the last should be the best guide to config, idk, what do you think guys?
This is the error that i am receiving

I am using the cloud Version 0.202.1

1 Like

Hi @Gabriele_Bracciali, n8n should handle most OAuth2 logic behind the scenes, including the MS Graph one, though you might need to experiment a bit with the correct settings (which would depend on the exact API endpoints you are using). You should be able to simply create generic OAuth2 credentials.

When creating these credentials through the n8n UI, you might find it helpful to take a look at the settings used by the existing n8n node credentials.

On another note, if you’re thinking about managing existing contacts using the MS Graph API, you might want to wait until this overhaul of the Outlook node is complete which would add such functionality to the existing node.

2 Likes

Hey @MutedJam , thanks for answer me.
Okay i’ve setted up the HTTP request like this:

But It return me this error, but it’s better than before, cause i’ve connected successfully the MS account

credential:
Authorization URL *
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
Access Token URL *
https://login.microsoftonline.com/common/oauth2/v2.0/token
Scope
openid offline_access User.read
Auth URI Query Parameters
response_mode=query
Authentication
Body

So, this would be an error coming from Microsoft, not n8n. I am not familiar with the API, so don’t know what exactly causes such a response, but googling a bit could suggest this is a problem with your Microsoft subscription not allowing access to a specific resource.

Are you using a private MS account or a business subscription to MS365?

1 Like

Okay yes i think so.
I am using a working MS365 account, but i guess it’s not all configured like aspect, I will search on google to find a solution to this error, and maybe post it here!

Post Edit:
I found this article

Should be this the reason…

1 Like

Cool, I’ll also see if I can get this to work. It feels vaguely familiar, but the MS365 APIs are nothing I use every day.

1 Like

Okay, I was able to read contacts like so:

  1. Create new OAuth2 API credentials in n8n, this will show a redirect URL required for the next step:

  2. Register a new application in the Azure portal under “App registrations”, specifying the redirect URL from step 1:

  3. Copy the client ID from the Azure portal and add it to the n8n credentials:

  1. Copy the authorization and token URLs from the endpoint section in the Azure portal and add them to the n8n credentials:

  1. Create a client secret and add it to n8n (make sure to copy the secret value and not the ID):

  1. In the final step, add scopes such as offline_access openid email profile OrgContact.Read.All Contacts.ReadWrite

Now you’re ready to connect n8n with MS365. Confirm the permissions when asked:

You should be able to run the workflow from your last thread around this. You can also append another node to fetch an individual contact using the endpoint you have shared above:

This works as it should:

If this still fails for you with the initial error message your best bet would be to reach out to Microsoft’s support team directly to find out which permissions might be missing, leading to this error.

3 Likes

Thanks for your help, really appreciate it.
This is definitely the guide for do it

1 Like

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