web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Web API, generate new Access Token from Refresh Token

(1) ShareShare
ReportReport
Posted on by 5

Hello,

We are using the Web API to access our Dynamics 365 Online CRM.

So far we have been manually generating our Access Token, which gives us a one hour access window.

We have been unable to find the correct series of parameters for programmatically generating a new Access Token from our Refresh Token.

Right now we do not want to use the SDK, ADAL or any other library to achieve this.  Just a basic web call.

Here is an example of how we achieve this at a different site utilizing OAUTH2 security:

WebRequest request = WebRequest.Create("https://accounts.site.com/oauth/v2/token?client_id=<id>&client_secret=<secret>&grant_type=refresh_token&refresh_token=<refresh  token>");
request.Method = "POST";
WebResponse response = request.GetResponse();

Stream dataStream = response.GetResponseStream();

StreamReader reader = new StreamReader(dataStream);

string responseFromServer = reader.ReadToEnd();

reader.Close();

dataStream.Close();

response.Close();

AccessToken at = JsonConvert.DeserializeObject<AccessToken>(responseFromServer);

A very simple POST call using ClientID, ClientSecret and RefreshToken to generate a new AccessToken.  Exactly what I am looking to do in Dynamics 365 API.  But, I cannot find the permutation of parameters that will work in Dynamics to accomplish this.

Has anyone been able to accomplish this with Dynamics 365 Online?

Thanks.

Bryan Hunt

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Bryan,

    I'm in the same page and looking for the solution.

    Now I've Dynamics 365 online WEB API to access the accounts etc...

    This CRM WEB API + My Wrapper API --> will be in Azure so I can give the API to the third party clients to access on methods

    I'm looking for security purpose so I want to use oAuth2 to generate tokens. So based on token I will allow the methods if Token is matching from the client side. 

    Do you have any idea or post any links that would be really helpful.

    I'm not using Azure AD at all here. 

    Regards,

    Satya

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans