[英]404 Not Found for oauth2/v2.0/token endpoint of Azure AD B2C
[英]Azure AD B2C -> OAuth2 -> Azure Function App Token Exchange
我對身份驗證、令牌交換和 Azure AD B2C 還很陌生。
我在我的門戶中構建了一個 Azure AD B2C 租戶,並將重定向 URI 設置為本地主機(我在 Visual Studio 上本地運行的一個 Azure 函數)。 我知道在瀏覽器將您帶到重定向 URI 后,它會通過 URI 傳回 authorization_code,我可以將該代碼作為變量保存在我的函數中,但恐怕我不知道在那之后該怎么做. VS
[FunctionName("Login")]
public static string Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
string name = req.Query["code"];
return name;
}
我知道我必須向 /token 端點發出 POST 請求,但是當我傳入 authorization_code 時,我在郵遞員中得到了這個回復
{
"error": "invalid_request",
"error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: a79790d9-5ab8-488e-bd5a-0e1feecd1d00\r\nCorrelation ID: 6f065d48-61d3-4193-99bf-e14f3a6951aa\r\nTimestamp: 2020-01-23 20:45:33Z",
"error_codes": [
900144
],
"timestamp": "2020-01-23 20:45:33Z",
"trace_id": "a79790d9-5ab8-488e-bd5a-0e1feecd1d00",
"correlation_id": "6f065d48-61d3-4193-99bf-e14f3a6951aa",
"error_uri": "https://login.microsoftonline.com/error?code=900144"
}
從我的函數中,我如何將這些參數傳遞到正文到 /token 端點? 任何幫助,將不勝感激。 最好。
該錯誤表明您使用的是 AAD 令牌端點,而不是 AAD B2C 令牌端點。
AAD B2C 的正確端點位於此處。 https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-oidc#send-authentication-requests
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.