Azure Active Directory 授权"访问令牌来自错误的颁发者"



我正在尝试实现它,但遇到了一个错误:

{
 "error": {
"code": "InvalidAuthenticationTokenTenant",
"message": "The access token is from the wrong issuer 'https://sts.windows.net/id/'. It must match the tenant 'https://sts.windows.net/id/' associated with this subscription. Please use the authority (URL) 'https://login.windows.net/id' to get the token. Note, if the subscription is transferred to another tenant there is no impact to the services, but information about new tenant could take time to propagate (up to an hour). If you just transferred your subscription and see this error message, please try back later."
}
}

非常感谢您的帮助。谢谢

更新:这是代码:

 public static string GetAccessToken()
    {
        var authenticationContext = new AuthenticationContext("https://login.windows.net/tenant-id");
        var credential = new ClientCredential(clientId: "client-id", clientSecret: "key");
        var result = authenticationContext.AcquireToken(resource: "https://management.core.windows.net/", clientCredential: credential);
        if (result == null)
        {
            throw new InvalidOperationException("Failed to obtain the JWT token");
        }
        string token = result.AccessToken;
        return token;
    }

此外,是否有用于定价计算器的API?感谢

原因是:我们针对普通租户进行了身份验证,但现在我们正在尝试从属于单独租户的订阅访问数据,而我们没有这个新租户的AccessToken。

在这种情况下,我们要做的是为相同的用户和客户端ID获取一个新的AccessToken(JWT),但授权租户进行我们选择的订阅。

即,我们有一个AccessToken,但它是一个常见的租户AccessToken,因此在授权方面受到限制:为了使用特定订阅的特定资源,我们现在需要该特定订阅和租户的AccessToken。

要做到这一点,我们只需要使用用户选择的订阅的TenantId,而不是使用"common"的Tenant。

请参阅上的步骤3http://www.bizbert.com/bizbert/2015/11/16/Listing+订阅+And+Logic+Apps+From+NET.aspx获取详细信息。

相关内容

最新更新