2017-11-17 4 views
1

Facebook, 다른 AAD 및 로컬 계정을 사용하여 인증을 사용하여 Azure AD B2C 거주자 및 앱을 보유하고 있습니다. B2C의 사용자는 등록시 채워지고 JWT 토큰에서 클레임으로 사용되는 일부 사용자 정의 필드가 있습니다.맞춤 Azure 광고 B2C 사용자 프로필 속성 값을 얻는 방법

그러나이 필드 값은 Azure 포털이나 Microsoft Graph API를 사용하여 볼 수 없습니다.

저장 위치 및 액세스 방법은 무엇입니까?

답변

3

사용자 정의 클레임에 액세스하려면 응용 프로그램에 전송 된 토큰에 포함 시키거나 Azure AD Graph API (아직 Microsoft Graph가 아님)을 쿼리하십시오. 토큰 사용자 지정 클레임 포함

  1. : 애저 포털의 B2C 블레이드에서 편집, 응용 프로그램의 주장을 클릭, 당신이 사용하는 정책을 선택하고 사용자 정의 속성을 선택합니다. Full documentation
  2. Azure AD 그래프 API 쿼리 : Azure AD 어플리케이션을 등록하고 Azure AD Graph API를 쿼리하십시오. 여기

Full documentation 사용자 정의 요구를 포함하려면이 안내서를 참조 # 2

// The client_id, client_secret, and tenant are pulled in from the App.config file 
var clientId = "YOUR_CLIENT_ID"; 
var clientSecret = "YOUR_CLIENT_SECRET"; 
var tenant = "yourtenant.onmicrosoft.com"; 

var userObjectID = "OID_OF_THE_USER" 
var query = "https://stackoverflow.com/users/" + userObjectId 

this.authContext = new AuthenticationContext("https://login.microsoftonline.com/" + tenant); 

// The ClientCredential is where you pass in your client_id and client_secret, which are 
// provided to Azure AD in order to receive an access_token using the app's identity. 
this.credential = new ClientCredential(clientId, clientSecret); 

// First, use ADAL to acquire a token using the app's identity (the credential) 
// The first parameter is the resource we want an access_token for; in this case, the Graph API. 
AuthenticationResult result = authContext.AcquireToken("https://graph.windows.net", credential); 

// For B2C user managment, be sure to use the Azure AD Graph API for now. 
HttpClient http = new HttpClient(); 
string url = "https://graph.windows.net/" + tenant + api + "?" + Globals.aadGraphVersion; 
url += "&" + query; 

// Append the access token for the Graph API to the Authorization header of the request, using the Bearer scheme. 
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url); 
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken); 
HttpResponseMessage response = await http.SendAsync(request); 

if (!response.IsSuccessStatusCode) 
{ 
    string error = await response.Content.ReadAsStringAsync(); 
    object formatted = JsonConvert.DeserializeObject(error); 
    throw new WebException("Error Calling the Graph API: \n" + JsonConvert.SerializeObject(formatted, Formatting.Indented)); 
} 

return await response.Content.ReadAsStringAsync(); 
1

에 대한 몇 가지 C# 코드입니다/당신의 JWT 속성 : Use the Azure AD Graph APIsample app에 : Use custom attributes to collect information about your consumers


이 설명서를 참조하십시오 Azure AD Graph API를 통해 사용자 정의 클레임을 볼 수 있습니다. 그들이 다시로 올 것이다 그래프 API에서

는 : extension_[GUID]_[ClaimName]

+0

당신은 내가 [GUID] 부분을 얻을 수있는 나를 찾는 데 도움이 될 수 있습니까? –

+0

두 가지 선택 : 샘플 광고 그래프 API 응용 프로그램에서'b2c get-user'를 실행하고 출력을 봅니다 (사용자에게 확장 속성이 설정된 것으로 가정). 2) azure portal에서 'ad app registrations -> b2c-extensions-app -> properties -> app id'를 엽니 다. 당신은 다른 질문을하고 싶을 수도 있습니다 ... @DmitryTabakerov – spottedmahn