Hi All,
I have a web application were i need to pull all the users from a given group present in Azure active directory.
When i login to the web site , able to pull the users present in the group, but after certain period ( say like 3 to 4 hrs ) encountering an error as below
{"odata.How to renew the token or else how to create a valid token
as of now using the below code
// Get a token for calling the Windows Azure Active Directory Graph
AuthenticationContext authContext = new AuthenticationContext(String.Format(CultureInfo.InvariantCulture,LoginURL, tenantId));
ClientCredential credential = new ClientCredential(Clientid,clientkey);
AuthenticationResult assertionCredential = authContext.AcquireToken(GraphURL, credential);
string authHeader = assertionCredential.CreateAuthorizationHeader();
string requestUrl = String.Format(
CultureInfo.InvariantCulture,
ConfigHelper.AdminGraphUserUrl,
HttpUtility.UrlEncode(tenantId));
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
request.Headers.TryAddWithoutValidation("Authorization", authHeader);
HttpResponseMessage response = await client.SendAsync(request);
string responseString = await response.Content.ReadAsStringAsync();
dynamic dynJson = JsonConvert.DeserializeObject(responseString);
Thanks,
Sai.