How to refresh the expired Oauth token to be active again in dynamic AX 2012,
How to refresh the expired Oauth token to be active again 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
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=..."
André Arnaud de Cal...
293,265
Super User 2025 Season 1
Martin Dráb
231,927
Most Valuable Professional
nmaenpaa
101,156
Moderator