如何使用没有客户端密钥的 Azure 广告,仅使用客户端 ID 和租户 ID?

问题描述 投票:0回答:2

我的问题是,如果我没有客户端密码,如何使用天蓝色广告在网络应用程序中应用用户身份验证。我只有 client-id 和tenant-id。我将感谢您的快速回复。

java azure authentication azure-active-directory
2个回答
1
投票

AFAIK 当我们使用 Azure AD 进行身份验证时,无需在 Web 应用程序中使用客户端密钥。

使用 Azure AD 验证您的应用程序时,您的代码片段将如下所示:

{  
"AzureAd": {  
"Instance": "https://login.microsoftonline.com/",  
"ClientId": "*******************************",  
"TenantId": "*******************************",  
"CallbackPath": "https://localhost/signin-oidc"
}

如果您想通过 Postman 获取访问令牌而不使用客户端密钥,您可以使用 ROPC 流程,如下所示:

  • 在 Postman 中,转到 Authorization 选项卡并选择类型为

    Oauth2.0

  • 转到 Headers 选项卡并包含

    Content-Type
    键并将值指定为 application/x-www-form-urlencoded

  • Body选项卡中,包括 client_id、grant_type、

    username
    password
    等参数和范围,如下所示:

您将获得访问令牌,如下所示:


0
投票

{ “错误”:“无效的授权”, “error_description”:“AADSTS50126:由于用户名或密码无效,验证凭据时出错。跟踪 ID:0bc4b188-c774-48c1-a635-f46e6f5c2e00 相关 ID:712f17ce-ebd0-4aed-a07e-48cdea3bef42 时间戳:2024-04-07 09: 49:45Z", “错误代码”:[ 50126 ], “时间戳”:“2024-04-07 09:49:45Z”, “trace_id”:“0bc4b188-c774-48c1-a635-f46e6f5c2e00”, “correlation_id”:“712f17ce-ebd0-4aed-a07e-48cdea3bef42”, “error_uri”:“https://login.microsoftonline.com/error?code=50126” }

即使 upn 是正确的,我也会收到此错误

© www.soinside.com 2019 - 2024. All rights reserved.