[英]Error fetching Azure AD B2C token
我正在將Azure AD B2C用於我的Web應用程序的用戶身份要求。 我正在使用ASP.NET Core 2.0 Razor Pages項目來構建Web應用程序。
如果用戶在嘗試訪問網頁時未通過身份驗證,則會將他們路由到Azure AD B2C登錄頁面。 如果成功通過驗證,它們將返回到我的Web應用程序。
我正在嘗試使用此文檔https://docs.microsoft.com/zh-cn/azure/active-directory-b2c/active-directory-b2c-access-tokens來獲取返回的JWT令牌
我不斷收到以下錯誤:
我正在使用以下代碼來檢索令牌。
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);
從Azure AD B2C返回的聲明似乎包含在User.Claims對象中。
if (User.Identity.IsAuthenticated)
{
Claim emailClaim = User.Claims.FirstOrDefault(claim => claim.Type == "emails");
Claim isNewClaim = User.Claims.FirstOrDefault(claim => claim.Type == "newUser");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.