0
Azure AD를 쿼리하고 주어진 사용자의 세부 정보를 가져 오는 간단한 C# 콘솔 응용 프로그램을 개발 중입니다. 나는 하늘 광고에 대해 많은 유용한 기사를 찾았지만 그들 중 누구도 내 목적을 달성하지 못했습니다. GitHub에 게시 된 샘플 코드는 너무 길고 복잡합니다. 나는 아래의 코드를 사용하고,하지만 난 토큰 오류가 점점 오전 :C# 콘솔 응용 프로그램을 사용하여 Azure AD 쿼리
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
/* OAuth2 is required to access this API. For more information visit:
https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */
// Specify values for the following required parameters
queryString["api-version"] = "1.6";
// Specify values for path parameters (shown as {...})
// var uri = "https://graph.windows.net/microsoft.onmicrosoft.com/users/{[email protected]}?" + queryString;
var uri = "https://graph.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/users?api-version=1.6";
var response = await client.GetAsync(uri);
if (response.Content != null)
{
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
내가 더 토큰 액세스를 검색하고 아래 코드를 광고에 내 응용 프로그램을 등록 및 사용 :
var authContext = new AuthenticationContext("AUTHORITY");
string token;
try
{
//var authresult = authContext.AcquireToken("MYAPP_ID", "MYAPP_CLIENTID", "MYAPP_REDIRECTURI");
var authresult = authContext.AcquireToken("https://graph.windows.net", "23b1c65e-5a20-4b88-a474-85c0845782c7", "https://localhost/");
token = authresult.AccessToken;
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
을 그러나 필요한 결과를 얻는 것은 아닙니다. 도와주세요!!!
응용 프로그램 ID는 clientid입니다. –
또한 코드는 사용자의 PlatformParameters 및 Token에서 빌드 오류를 표시합니다. – dotnetman
platformParamerters에 대한 어셈블리 참조가 필요합니까? – dotnetman