나는이 코드 샘플을 사용합니다 : https://github.com/Azure-Samples/active-directory-dotnet-graphapi-web,이 코드 샘플은 클라이언트 라이브러리를 사용하고 있지만, (httpclient를 사용하여) perfmon 쿼리를 사용하려면 api 호출을 직접 사용하려면 아래 코드를 사용하여 액세스 토큰을 얻습니다. 캐시 :캐시에서 토큰을 찾을 수 없으므로 토큰을 자동으로 획득하지 못했습니다. 호출 메서드 AcquireToken
string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
AuthenticationContext authContext = new AuthenticationContext(Startup.Authority, new NaiveSessionCache(userObjectID));
ClientCredential credential = new ClientCredential(clientId, appKey);
var result = await authContext.AcquireTokenSilentAsync(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
하지만 난 항상 오류 던졌다 발견 : 더 토큰이 캐시에서 발견되지 않았다으로 토큰을 자동으로 획득하는 데 실패합니다. 통화 방법 AcquireToken
이 시나리오를 테스트하려면 로그 아웃하고 다시 로그인 해 보셨습니까? –