PowerBI AADSTS90002:找不到租户授权
PowerBI AADSTS90002: Tenant authorize not found
我已将示例解决方案中的必要代码移至我的解决方案,但在验证时出现以下错误:
AADSTS90002: Tenant authorize not found. This may happen if there are
no active subscriptions for the tenant. Check with your subscription
administrator.
我正在使用这两行进行身份验证:
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential);
错误发生在最后一行。以下是我的 web.config:
中的值
<add key="authorityUrl" value="https://login.windows.net/common/oauth2/authorize/" />
<add key="resourceUrl" value="https://analysis.windows.net/powerbi/api" />
同样,这在示例应用程序中 100% 有效,但在我移至我的应用程序时却无效。有什么想法吗?
在此先感谢您的帮助。
所以经过一些研究,我发现它与以下 nuget 包的版本有关:
Microsoft.IdentityModel.Clients.ActiveDirectory
Microsoft.PowerBI.Api
需要使用以下版本:
Microsoft.IdentityModel.Clients.ActiveDirectory v3.13.9
Microsoft.PowerBI.Api V2.0.12
好像跟使用的端点有关系。如果您降级到以上版本(与提供的示例工具中使用的版本相同),那么它就可以工作了。
最新版本使用类似这样的东西:https://login.microsoftonline.com/common/
其中提供的相同版本使用:https://login.windows.net/common/oauth2/authorize/
一旦我 "downgraded" 我的版本,它就通过了身份验证!
希望这对其他人有帮助。
通过将程序集“Microsoft.IdentityModel.Clients.ActiveDirectory”还原为版本=3.13.9.1126.
解决
使用此程序集的最新版本引发了此问题。版本 = 4.4.0.0
在我的例子中,我没有降级 Microsoft.IdentityModel.Clients.ActiveDirectory
,而是将身份验证端点从 https://login.windows.net/{My tenant}/oauth2/token
更改为 https://login.microsoftonline.com/{My tenant}
,这解决了问题。
是的,所有答案都是正确的,我只是想说明一下为什么它在低版本而不是新版本中工作
根据 official doc,这是来自 Microsoft
的更好的权限验证更新
ADAL.NET 4.x is also less forgiving than ADAL 3.x when setting the
authority in the constructor of AuthenticationContext. Valid
authorities should be, in the case of Azure AD v1.0:
- https://login.microsoftonline.com/{Guid}, where the Guid is the tenant ID
- https://login.microsoftonline.com/domainName, where the domain name is a domain associated with your tenant
https://login.microsoftonline.com/common which, in the case of ADAL.NET means any Azure AD tenant (note that the meaning is
different in MSAL.NET)
It cannot be https://login.microsoftonline.com/common/OAuth2/endpoint
even if this for could have been wrongly accepted in ADAL 3.x
修复非常简单,但很难从 Microsoft Docs 中找到它,因为它们非常庞大。所以我要分享对我们有用的东西。
请注意,我们使用 AuthenticationContext
结合 ClientCredential
来获取令牌。
3.x
版本的 AuthorityUrl 是 - https://login.windows.net/{yourOrg}/oauth2/token
升级到4.x
以后应该改为-https://login.microsoftonline.com/{yourOrg}
万一你想知道完整的代码只有 2 行
var authenticationContext = new AuthenticationContext(AppSettings.AuthorityUri);
var token = authenticationContext.AcquireTokenAsync(AppSettings.ResourceUri, new ClientCredential(AppSettings.ClientId, AppSettings.ClientSecret)).GetAwaiter().GetResult();
我已将示例解决方案中的必要代码移至我的解决方案,但在验证时出现以下错误:
AADSTS90002: Tenant authorize not found. This may happen if there are no active subscriptions for the tenant. Check with your subscription administrator.
我正在使用这两行进行身份验证:
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential);
错误发生在最后一行。以下是我的 web.config:
中的值<add key="authorityUrl" value="https://login.windows.net/common/oauth2/authorize/" />
<add key="resourceUrl" value="https://analysis.windows.net/powerbi/api" />
同样,这在示例应用程序中 100% 有效,但在我移至我的应用程序时却无效。有什么想法吗?
在此先感谢您的帮助。
所以经过一些研究,我发现它与以下 nuget 包的版本有关:
Microsoft.IdentityModel.Clients.ActiveDirectory
Microsoft.PowerBI.Api
需要使用以下版本:
Microsoft.IdentityModel.Clients.ActiveDirectory v3.13.9
Microsoft.PowerBI.Api V2.0.12
好像跟使用的端点有关系。如果您降级到以上版本(与提供的示例工具中使用的版本相同),那么它就可以工作了。
最新版本使用类似这样的东西:https://login.microsoftonline.com/common/
其中提供的相同版本使用:https://login.windows.net/common/oauth2/authorize/
一旦我 "downgraded" 我的版本,它就通过了身份验证!
希望这对其他人有帮助。
通过将程序集“Microsoft.IdentityModel.Clients.ActiveDirectory”还原为版本=3.13.9.1126.
解决使用此程序集的最新版本引发了此问题。版本 = 4.4.0.0
在我的例子中,我没有降级 Microsoft.IdentityModel.Clients.ActiveDirectory
,而是将身份验证端点从 https://login.windows.net/{My tenant}/oauth2/token
更改为 https://login.microsoftonline.com/{My tenant}
,这解决了问题。
是的,所有答案都是正确的,我只是想说明一下为什么它在低版本而不是新版本中工作
根据 official doc,这是来自 Microsoft
的更好的权限验证更新ADAL.NET 4.x is also less forgiving than ADAL 3.x when setting the authority in the constructor of AuthenticationContext. Valid authorities should be, in the case of Azure AD v1.0:
- https://login.microsoftonline.com/{Guid}, where the Guid is the tenant ID
- https://login.microsoftonline.com/domainName, where the domain name is a domain associated with your tenant
https://login.microsoftonline.com/common which, in the case of ADAL.NET means any Azure AD tenant (note that the meaning is
different in MSAL.NET)It cannot be https://login.microsoftonline.com/common/OAuth2/endpoint even if this for could have been wrongly accepted in ADAL 3.x
修复非常简单,但很难从 Microsoft Docs 中找到它,因为它们非常庞大。所以我要分享对我们有用的东西。
请注意,我们使用 AuthenticationContext
结合 ClientCredential
来获取令牌。
3.x
版本的 AuthorityUrl 是 - https://login.windows.net/{yourOrg}/oauth2/token
升级到4.x
以后应该改为-https://login.microsoftonline.com/{yourOrg}
万一你想知道完整的代码只有 2 行
var authenticationContext = new AuthenticationContext(AppSettings.AuthorityUri);
var token = authenticationContext.AcquireTokenAsync(AppSettings.ResourceUri, new ClientCredential(AppSettings.ClientId, AppSettings.ClientSecret)).GetAwaiter().GetResult();