2017-11-14 4 views
1

エラーが発生しましたAADSTS70002:資格情報の検証中にエラーが発生しました。 AADSTS50012:クライアントのアサーションオーディエンス要求がRealm発行者デーモンMSALからMSGraphを使用

と一致しません。

string[] scopes = new string[]{"https://graph.microsoft.com/.default"}; 
var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); 
certStore.Open(OpenFlags.ReadOnly); 
var cert = certStore.Certificates.Cast<X509Certificate2>().First(c => c.Thumbprint == "XXX-XXX etc"); 
var cas = new ClientAssertionCertificate(cert); 
var cc = new Microsoft.Identity.Client.ClientCredential(cas); 
var client = new Microsoft.Identity.Client.ConfidentialClientApplication("XX-XXX etc", "http://localhost", cc, new TokenCache(), new TokenCache()); 
var authResult = await client.AcquireTokenForClientAsync(scopes); 
var dap = new DelegateAuthenticationProvider(rm => 
{ 
    rm.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", authResult.AccessToken); 
    return Task.FromResult(0); 
}); 
var gClient = new GraphServiceClient(dap); 
gClient.Me.Dump(); 

AcquireTokenForClientAsync()メソッドの呼び出しでエラーが発生しました。

ユーザー認証ができないMSALおよびデーモンクライアントのオンラインドキュメントは見つかりません。

提案?

答えて

0

問題が見つかりました。私はConfidentialClientApplicationコンストラクタの2番目のオーバーロードを使用し、このような権限を与える必要がありました。

string authorityFormat = "https://login.microsoftonline.com/{0}/v2.0"; 
string tennantId = "xxx-xx-xx"; 

その後、

var client = new Microsoft.Identity.Client.ConfidentialClientApplication("xxx-x-xx etc", string.Format(authorityFormat, tennantId), "http://localhost", cc, new TokenCache(), new TokenCache());

コードHereは正しい方向に私を指摘しました。

関連する問題