HTTP Node with OAuth2 credentials for Microsoft Dynamics

Hey all!

As the current Microsoft Dynamics node has some limitations, I am using the HTTP node. I set up the OAuth2 credential and it works fine.

The problem I am facing now is regarding the token lifetime of 3600s. There is no way I can change this value. I tried to set up a Conditional Access but I was not able to do so.

Could someone point me to the right direction here?

Thanks a lot!
Victor Pantoja

Hi @victorpantoja, this could suggest a missing query parameter or scope. Several services won’t issue refresh tokens unless the correct values are provided. I don’t know about Dynamics CRM specifically, but for other Microsoft APIs the offline_access scope would be required for refresh tokens to be issued.

That said, it can be tricky to get this right and one major limitation of n8n is that it doesn’t provide much user-facing information on the OAuth2 process (we have an open bug ticket for this as ADO-147, but I don’t know when or if it will be picked up unfortunately), so you might need to test a few different settings for the time being.

This post would have a few relevant settings that worked for me (and ultimately also @0101binary0101) when connecting to Exchange/Outlook365 which might help you with getting started as well.

Thanks for your answer, @MutedJam !

I had already given this permission in Azure. It seems that the token is simply not getting refreshed. I have to manually reconnect my account every 3600s, which of course is not what we want. Maybe I need to set something as “Auth URI Query Parameters”?

Hey @victorpantoja,

Are you using the predefined Microsoft Dynamics credential or a generic oauth2 credential?

Hi @Jon

I am actually using a generic OAuth2 credential as the Dynamics node doesn’t do what I need to do.

Hey @victorpantoja,

You should be able to still use the credentials for the node even if you don’t use it which could be useful, In the node for the scopes we use…

openid offline_access https://{{$self.subdomain}}.{{$self.region}}/.default

If your Dynamics URL was you would use…

openid offline_access

We also use a query parameter of response_mode=query

1 Like