2016-04-26 22 views
0

は、私が働いているMicrosoft graph sample appOffice 365のAPIはMicrosoftグラフ認証が

そして標準のログインからサンプルアプリを登録できなかったが、私はこのコードを使用してsimplierそれを作るしようとすると:私は次のエラーを取得する

 var authContext = new AuthenticationContext(Settings.AzureADAuthority); 

     var token = authContext.AcquireToken(Settings.O365UnifiedAPIResource, new ClientCredential(Settings.ClientId, Settings.ClientSecret)).AccessToken; 

を:Application with identifier '[ClientId here]' was not found in the directory microsoft.com

Setting.O365UnifiedAPIResource = @"https://graph.microsoft.com/"; 
Settings.AzureADAuthority = @"https://login.microsoftonline.com/common"; 

誰でも問題が分かるでしょうか?

+0

あなたSettings.ClientIdをチェックし、あなたがあなたのサンプルアプリケーションを登録するときに取得クライアントIDの文字列を使用して、プロジェクト内の[ここClientIdを]を置き換えたのですか? @Aleksa。 – Jackie

+1

私は前と同じ問題に会った。 AzureADAuthorityを "https://login.microsoftonline.com/YourTenantName"として変更することができます。その後、コードが動作します。 –

+0

@NanYuありがとう:) – Aleksa

答えて

2
Settings.AzureADAuthority = @"https://login.microsoftonline.com/{tenant_id or tenant_name}"; 

クライアントクレデンシャル(クライアントID +クライアントシークレット)を使用してトークンを取得する場合。テナントを明示的に指定する必要があります。例えば

https://login.microsoftonline.com/ {tenant_id}

又は

https://login.microsoftonline.com/ {your_domain.onmicrosoft.com}

ところで、この登録は、サンプルアプリケーションのためになるように、それは意志権限を委任されたMail.Sendアクセス許可のみが必要です。アプリトークンを取得するには、ユーザートークンではなくアプリトークンを取得しているため、Azure ADにアプリレベルの権限を付与する必要があります。

enter image description here

関連する問題