2017-12-30 63 views
2

私はMSAL.jsを使用しており、FacebookをIDプロバイダとして使用してAzure AD B2Cのユーザーを正常にサインイン/サインアップすることができます。問題は、サインイン後にユーザーのプロフィール画像を取得できないことです。Azure AD B2Cを使用してFacebookのプロフィール画像を取得する方法

Azure AD B2Cは、ユーザーのFacebook IDとのつながりのないオブジェクト識別子を返します。

+0

カスタムポリシーを使用していますか? –

+0

いいえ、カスタムポリシーを使用することを理解する限り、広告b2cプレミアムアカウントを取得する必要があります。 – armache

+0

こんにちは@armache。カスタムポリシーは、Azure AD B2Cテナントの動作を定義する設定ファイルです。彼らは特別なテナントを必要としません。以下では、Facebookユーザーのピクチャフィールドを取得し、カスタムポリシーを使用してIDトークンで画像の主張を発行する方法を紹介しました。 –

答えて

7

カスタムポリシーを使用すると、Facebookユーザーのピクチャフィールドを取得し、次のようにIDトークンで画像の主張を発行できます。

1:SocialAndLocalAccountsなどのソーシャルアカウントポリシーのいずれかを使用してAzure Active Directory B2C: Get started with custom policiesステップを完了します。

2:

<ClaimType Id="picture"> 
    <DisplayName>Picture</DisplayName> 
    <DataType>string</DataType> 
</ClaimType> 

3:the extensions fileにおける「画像」クレームを宣言「Facebook-に「ClaimsEndpoint」メタデータ項目と「画像」出力クレームの両方に「ピクチャ」フィールドを追加OAuthの」the extensions policyでの技術的なプロフィール:

<ClaimsProvider> 
    <DisplayName>Facebook</DisplayName> 
    <TechnicalProfiles> 
    <TechnicalProfile Id="Facebook-OAUTH"> 
     <Metadata> 
     <Item Key="client_id">facebook_clientid</Item> 
     <Item Key="scope">email public_profile</Item> 
     <Item Key="ClaimsEndpoint">https://graph.facebook.com/me?fields=id,first_name,last_name,name,email,picture</Item> 
     </Metadata> 
     <OutputClaims> 
     <OutputClaim ClaimTypeReferenceId="picture" PartnerClaimType="picture" /> 
     </OutputClaims> 
    </TechnicalProfile> 
    </TechnicalProfiles> 
</ClaimsProvider> 

4:発行 ":

<RelyingParty> 
    <DefaultUserJourney ReferenceId="SignUpOrSignIn" /> 
    <TechnicalProfile Id="PolicyProfile"> 
    <DisplayName>PolicyProfile</DisplayName> 
    <Protocol Name="OpenIdConnect" /> 
    <OutputClaims> 
     <OutputClaim ClaimTypeReferenceId="displayName" /> 
     <OutputClaim ClaimTypeReferenceId="givenName" /> 
     <OutputClaim ClaimTypeReferenceId="surname" /> 
     <OutputClaim ClaimTypeReferenceId="email" /> 
     <OutputClaim ClaimTypeReferenceId="picture" /> 
     <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub"/> 
     <OutputClaim ClaimTypeReferenceId="identityProvider" /> 
    </OutputClaims> 
    <SubjectNamingInfo ClaimType="sub" /> 
    </TechnicalProfile> 
</RelyingParty> 
で絵" の主張を210
+0

多くの感謝のクリス、それは動作します。 – armache

関連する問題