Hi,
I have to query the graph API of the Azure Active Directory and get the current user's photo. I have the following code, but facing problem with it. I am able to acquire the token, but after the token is returned from AquireTokenandInvoke() method, the code just hangs. No exception is thrown not does it continue with the execution. The control doesn't return back to GetActiveDirectoryClient() function. Can anybody help on this ???
publicstaticasyncTask<string> AcquireTokenAndInvoke()
{
stringtoken = null;
try
{
AuthenticationContextauthContext = newAuthenticationContext("https://login.windows.net/tenant.com",false);
ClientCredentialclientCred = newClientCredential("clientcred","appkey");
AuthenticationResultres = awaitauthContext.AcquireTokenAsync("https://graph.windows.net/", clientCred);
if(res != null)
{
token = res.AccessToken;
}
else
{
id = "temp";
}
}
catch(Exceptione)
{
}
returntoken;
}
publicvoidGetActiveDirectoryClient()
{
try
{
UribaseServiceUri = newUri("https://graph.windows.net/tenant.com/");
ActiveDirectoryClientactiveDirectoryClient =
newActiveDirectoryClient(baseServiceUri,async() =>awaitAcquireTokenAndInvoke());
}
catch(Exceptione)
{
}
}