azure - 权限不在有效列表中 : 'authority' is not in the list of valid addresses

标签 azure authentication oauth active-directory access-token

我正在尝试从我的客户端应用程序调用经过身份验证的 API。但是,在进行 AcquireTokenAsync 时,我收到以下错误“authority_not_in_valid_list: 'authority' 不在有效地址列表中

这是我的代码片段:

resourceUrl = "https://myApiEndPoint.com";

var clientCredential =
     new ClientCredential( myClientAppId, myClientSecretKey );

//myClientAppId 和 myClientSecretKey 是来自 Azure 门户的值

var authContext = 
    new AuthenticationContext( "https://my_authority/myApiEndPoint");

return await authContext.AcquireTokenAsync( resourceUrl, clientCredential );

在我的应用程序客户端 ID 的 Azure 门户中,我已授予访问权限 https://myApiEndPOint.com API。

对于可能导致此问题的原因以及不在有效列表中意味着什么有什么想法吗?

最佳答案

我的理解是:

  • 您在 Azure 门户中创建了应用程序,因此权限是 Azure AD 终结点。因此权限大概是https://login.microsoftonline.com/common ?或者您有充分的理由使用“https://my_authority”吗?

  • 您已授予访问 API 的委托(delegate)权限。这意味着您的应用程序将以用户的名义访问 API。但是,您使用的 AcquireTokenAsync 方法正在使用“ClientCredential”流程(意味着使用应用程序 secret ) 您可能更想使用另一个覆盖来传递resourceUri、clientId...

如果这是您的用例,我建议您查看active-directory-dotnet-webapi-onbehalfof示例(参见here)

关于azure - 权限不在有效列表中 : 'authority' is not in the list of valid addresses,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46085415/

相关文章:

azure - 逻辑应用 - O365 连接器 - 多重身份验证

azure - 临时环境的 Azure 部署出现错误

c# - 客户端 WPF 应用程序如何通过 Azure 上的 WCF 服务进行身份验证?

Azure B2C 自定义策略 : How do you reset the TOTP settings in the event that a user lost access to there authenticator app?

java - 自定义页面登录表单以利用 spring 登录身份验证

node.js - 使用 Passport Consumer 策略设置全局 session

authentication - TouchID 转发到系统密码认证

Yelp API 的 Javascript OAuth

ruby - 使用 Omniauth 在 Ruby 中请求 Google 联系人

javascript - oauth2 重定向 url 如何用于桌面应用程序?