2016-12-05 77 views
0

我'M具有下面的代碼天青Active Directory和鱷梨API認證

string aadInstance = "https://login.windows.net/{0}"; 
string tenant = "<tenant>.onmicrosoft.com"; 
string clientId = "d22d1d2a-..."; 
Uri redirectUri = new Uri("http://redirect"); 

string authority = String.Format(aadInstance, tenant); 
string apiResourceId = "https://<resource>.onmicrosoft.com/sample"; 
string apiBaseAddress = "http://localhost:9003/"; 

AuthenticationContext authContext = authContext = new AuthenticationContext(authority); 
AuthenticationResult authResult = authContext.AcquireToken(apiResourceId, clientId, redirectUri); 

我已經添加了應用如在活動目錄原生應用和我是得到的錯誤。 「AADSTS50001:在名爲.onmicrosoft.com的租戶中未找到名爲.onmicrosoft.com/sample」> https://.onmicrosoft.com/sample的應用程序。如果應用程序尚未由租戶的管理員安裝或由租戶中的任何用戶同意,則可能會發生這種情況。您可能已將您的身份驗證請求發送給錯誤的租戶。「

我對什麼應該是apiresource id感到困惑,如果可能的話,請給我關於如何在本地和web api應用程序中配置應用程序的快照,其中應該是資源ID和租戶ID名稱等,我也很困惑「在其他應用程序的權限」,在我正在尋找「鱷梨」,這是不可見的

回答

0

根據錯誤消息,看來你使用不正確的資源當你請求的訪問令牌。

資源應該是APP ID URI其網絡API的本機應用程序消耗,你可以找到它通過老門戶就像下圖: enter image description here

我們也可以找到它的通過Azure的Active Directory中的新門戶 - >應用程序註冊 - > {你的應用程序} - >屬性:

enter image description here