今日、Windows Azure Active Directory の構成で、Web API の下に新しいエントリが表示されていることに気付きました。
以前に Windows Azure AD Graph にアクセスしたのと同じ方法で、自分のアプリケーションが Windows Azure Service Management Api にアクセスできるようになったようです。
コンセンサス付与に渡すことができる 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();
}
しかし、リクエストは失敗しました。「証明書が有効で、このサブスクリプションに関連付けられていることを確認してください」。トークンを処理するように更新されていないため、エラー メッセージは古くなっています。
私の推測では、ユーザーとのコンセンサスを行うときにアクセスを要求する必要があります。