I am using Azure AD B2C for my web application's user identity requirements. I'm using ASP.NET Core 2.0 Razor Pages project to build the web application.
If the user is not authenticated when trying to access a web page they are routed to the Azure AD B2C login page. They are then returned to my web app if successfully authenticated.
I am trying to get hold of the returned JWT token using this document https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-access-tokens
I keep getting the following error:
I am using the following code to retrieve the token.
string url = $"https://login.microsoftonline.com/{this._options.Domain}/oauth2/v2.0/authorize?";
string policy = this._options.SignUpSignInPolicyId;
string clientid = this._options.ClientId;
string grantType = "authorization_code";
Random random = new Random();
int nonce = random.Next();
string redirectUri = WebUtility.UrlEncode("https://localhost:44315/");
string scope = WebUtility.UrlEncode($"https://{this._options.Domain}/notes/openid");
const string responseType = "code";
string request =
$"{url}p={policy}" +
$"&client_id={clientid}" +
$"&grant_type={grantType}" +
$"&nonce={nonce}" +
$"&redirect_uri={redirectUri}" +
$"&scope={scope}" +
$"&response_type={responseType}";
var response = await GetData(request);