
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)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