Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How To Refresh token Oauth in Dynamic AX 2012

(0) ShareShare
ReportReport
Posted on by 5

How to refresh the expired Oauth token to be active again in dynamic AX 2012,

  • Dynamic AX 2012 Profile Picture
    5 on at
    RE: How To Refresh token Oauth in Dynamic AX 2012

    Hi Blue Wang, where i put the code if i have this code :

    public static void TestKoneksiOauth(Args _args)

       {

           int                                                      find;

           str                                                      url,aosUri,activeDirectoryTenant;

           str                                                      activeDirectoryClientAppId;

           str                                                      activeDirectoryClientAppSecret;

           str                                                      postData,activeDirectoryResource;

           str                                                      aadClientAppSecret,oAuthHeader;

           str                                                      returnValue,jsonString,jsondszstr;

           System.Net.HttpWebRequest                                request;

           System.Net.HttpWebResponse                               response;

           System.Byte[]                                            byteArray;

           System.IO.Stream                                         dataStream;

           System.IO.StreamReader                                   streamRead;

           System.IO.StreamWriter                                   streamWrite;

           System.Net.ServicePoint                                  servicePoint;

           System.Net.ServicePointManager                           servicePointmgr;

           System.Net.HttpVersion                                   version;

           CLRObject                                                clrObj;

           System.Text.Encoding                                     utf8;

           Counter                                                  countCounter;

           Object                                                   obj;

           Map                                                      data;

           System.Byte[]                                            byteArraynew;

           System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection();

           str  byteStr = strfmt('%1:%2', "axapta", "234adefasf234addd");

           new InteropPermission(InteropKind::ClrInterop).assert();

           headers = new System.Net.WebHeaderCollection();

           url = "testdata/listtransaction

           clrObj = System.Net.WebRequest::Create(url);

           request = clrObj;

           request.set_Method("GET");

           request.set_KeepAlive(true);

           request.set_ContentType("application/json");

           utf8    = System.Text.Encoding::get_UTF8();

           byteArraynew   = utf8.GetBytes(byteStr);

           byteStr     = System.Convert::ToBase64String(byteArraynew);

           //headers.Add("Authorization", 'Basic ' + byteStr);

           headers.Add("Authorization", "Bearer 56zsdfs-asdf2-sadf2-234adsf-12625gg2y2g");

           request.set_Headers(headers);

           servicePoint = request.get_ServicePoint();

           System.Net.ServicePointManager::set_Expect100Continue(false);

           System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);

           response = request.GetResponse();

           dataStream = response.GetResponseStream();

           streamRead = new System.IO.StreamReader(dataStream);

           jsonString = streamRead.ReadToEnd();

           dataStream.Close();

           response.Close();

       }

    Please advice

  • Blue Wang Profile Picture
    on at
    RE: How To Refresh token Oauth in Dynamic AX 2012

    Hi Vinodbadu,

    Try to use the refresh tokens to get new access tokens. We do this using the call "POST /{tenant}/oauth2/token grant_type=refresh_token&refresh_token=..."

    docs.microsoft.com/.../v1-protocols-oauth-code

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... 293,265 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,927 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans