2017-08-28 143 views
2

我實現了LinkedIn的註冊/登錄在通過自定義的政策,但是當我點擊LinkedinExchange按鈕,我得到了用戶出行播放器以下異常:Azure的AD B2C LinkedIn聲稱提供商

An exception was caught when making a request to URL " https://api.linkedin.com/v1/people/~:(id,first-name,last-name,formatted-name,email-address) " using method "Get". The exception status code was "ProtocolError" with the following message: The remote server returned an error: (401) Unauthorized.. The remote server returned an error: (401) Unauthorized.

這裏是LinkedIn的ClaimsProvider我說:

<ClaimsProvider> 
    <Domain>linkedin.com</Domain> 
    <DisplayName>Linkedin</DisplayName> 
    <TechnicalProfiles> 
    <TechnicalProfile Id="Linkedin-OAUTH"> 
     <DisplayName>Linkedin</DisplayName> 
     <Protocol Name="OAuth2" /> 
     <Metadata> 
     <Item Key="ProviderName">linkedin</Item> 
     <Item Key="authorization_endpoint">https://www.linkedin.com/oauth/v2/authorization</Item> 
     <Item Key="AccessTokenEndpoint">https://www.linkedin.com/oauth/v2/accessToken</Item> 
     <Item Key="AccessTokenResponseFormat">json</Item> 
     <Item Key="ClaimsEndpoint">https://api.linkedin.com/v1/people/~:(id,first-name,last-name,formatted-name,email-address)?format=json</Item> 
     <Item Key="HttpBinding">POST</Item> 
     <Item Key="UsePolicyInRedirectUri">0</Item> 
     <Item Key="client_id">XXXXXXXXXXXX</Item> 
     </Metadata> 
     <CryptographicKeys> 
     <Key Id="client_secret" StorageReferenceId="B2C_1A_LinkedinSecret" /> 
     </CryptographicKeys> 
     <OutputClaims> 
     <OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="id" /> 
     <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="emailAddress" /> 
     <OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="firstName" /> 
     <OutputClaim ClaimTypeReferenceId="surname" PartnerClaimType="lastName" /> 
     <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="formattedName" /> 
     <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="Linkedin" /> 
     <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="Linkedin" /> 
     </OutputClaims> 
     <OutputClaimsTransformations> 
     <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" /> 
     <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" /> 
     <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" /> 
     <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId" /> 
     </OutputClaimsTransformations> 
     <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" /> 
    </TechnicalProfile> 
    </TechnicalProfiles> 
</ClaimsProvider> 

是否有人看到我在做什麼錯?

+0

嘗試增加 oauth2_access_token – Saca

+0

非常感謝您,添加該項目解決了問題。現在我想了解需要添加這個Item,因爲Linkedin文檔說它返回一個'access_token'字段,當我執行API調用時,它確實返回字段'access_token'而不是'oauth2_access_token'。在azure B2C文檔中沒有任何地方可以看到字段oauth2_access_token ...... –

+0

oauth2指的是使用的協議,而不是字段的名稱,但是總體而言,您的反饋是關於點,這個(長定製策略中的其他一些東西)需要更好地記錄。 – Saca

回答

1

爲了增加LinkedIn爲通過自定義策略在Azure的AD B2C的身份提供者,請確保您有在ClaimsProvider的<Metadata>部分如下條目:

<Item Key="ClaimsEndpointAccessTokenName">oauth2_access_token</Ite‌​m>