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

时间:2016-05-17 08:08:46

标签: azure azure-active-directory

我试图实施this,但我遇到了错误:

{
 "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?感谢

1 个答案:

答案 0 :(得分:1)

原因是:我们针对共同租户进行了身份验证,但现在我们正在尝试从属于单独租户的订阅中访问数据 - 而且我们没有为此新租户提供AccessToken 。

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

即。我们有一个AccessToken,但它是一个普通的租户AccessToken,因此受限于授权:使用特定于特定订阅的资源,我们现在需要一个特定订阅和租户的AccessToken。

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

的租户。

有关详细信息,请参阅http://www.bizbert.com/bizbert/2015/11/16/Listing+Subscriptions+And+Logic+Apps+From+NET.aspx的第3步。

相关问题