0

今天我注意到在 Windows Azure Active 目录的配置中,web apis 下出现了一个新条目。

似乎我现在可以允许我的应用程序访问 Windows Azure 服务管理 Api,就像我们之前访问 Windows Azure AD Graph 一样。

我想知道我可以将什么样的 RequestedPermissions 范围传递给共识授予。到目前为止,我只使用过 DirectoryReaders。

在访问 Graph API 之前,此代码有效:

    string tenantId = ClaimsPrincipal.Current.FindFirst(TenantIdClaimType).Value;

    // Get a token for calling the Windows Azure Active Directory Graph
    AuthenticationContext authContext = new AuthenticationContext(String.Format(CultureInfo.InvariantCulture, LoginUrl, tenantId));
    ClientCredential credential = new ClientCredential(AppPrincipalId, AppKey);
    AuthenticationResult assertionCredential = authContext.AcquireToken(GraphUrl, credential);

我只是为使用 WAML 的管理 api 尝试了同样的事情。

    assertionCredential = authContext
        .AcquireToken("https://management.core.windows.net/",credential);


    using (var azure = new SubscriptionClient(new TokenCloudCredentials(assertionCredential.AccessToken)))
    {
        var subs = await azure.Subscriptions.ListAsync();
    }

但是请求失败了。“验证证书是否有效并与此订阅相关联”。错误消息已过时,因为它尚未更新以处理令牌。

我的猜测是,在与用户达成共识时,我需要请求访问权限。

4

0 回答 0