'AdalServiceException: Response status code does not indicate success: 406 (NotAcceptable)
I am getting the following type of error:
AdalServiceException: Response status code does not indicate success: 406 (NotAcceptable)
The code is for generating barier token for Azure Active Directory authentication based on a user name and password.
Also, what do I put in these variables, especially resource?
This is my code (.NET Core console application)
static void Main(string[] args)
{
Console.WriteLine(GetToken());
Console.ReadLine();
}
public static string tenantId = "********************************";
public static string clientId = "*******************************";
public static string resource = "(What to put in this)";
public static string username = "**************";
public static string password = "***********************";
public static string GetToken()
{
var upc = new UserPasswordCredential(username, password);
var context = new AuthenticationContext("https://login.microsoftonline.com/" + tenantId);
AuthenticationResult result = context.AcquireTokenAsync(resource, clientId, upc).Result;
return result.AccessToken;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
