Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Dynamics Web API - Refresh Token

(0) ShareShare
ReportReport
Posted on by

I am using the Dynamics Web API and Microsoft.IdentifyModel.Clients.ActiveDirectory package to connect to Dynamics from an Azure Function (.NET Core) app.

My connection is pretty standard,

        var clientCred = new ClientCredential(AppClientId, AppClientSecret);

            result = await _context.AcquireTokenAsync(DynamicsTenantUrl, clientCred);
            Token = result.AccessToken;

However, the application I have built this connection for has a long-running operation that eventually gets a "Not Authorized" back from Dynamics because the token has expired.

I have looked around at a couple of examples where I need to get the refresh_token back in order to then request that piece of information to keep the connection going, however the above does not give me a refresh token.

I have tried doing the AcquireTokenSilentAsync method and even though it shows a token in the TokenCache it always returns "No token available."

Is there a way to do this with the current implementation or do I need to change my connection code completely to access this token?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans