2017-12-09 8 views
0

私はカスタムポリシーを使用してAzure AD B2CのカスタムプロバイダとしてGitHubを設定しています。私はログインページに到達し、正常に正しいAzure広告リンクにリダイレクトすることができますが、Azure AD B2Cのサーバーエラーは常にOAUTHの2番目の部分を拒否します。Azure AD B2C - GitHubのカスタムプロバイダはアクセストークンを取得できません

アプリ痕跡のトレースログを見ると、「無効なOAuth応答が受信されました」と「値の解析中に予期しない文字が見つかりました:」というメッセージが表示されます。ここで私が設定したポリシー・プロバイダは、次のとおりです。

<ClaimsProvider> 
     <Domain>github.com</Domain> 
     <DisplayName>GitHub</DisplayName> 
     <TechnicalProfiles> 
     <TechnicalProfile Id="GitHub-OAUTH"> 
      <DisplayName>GitHub</DisplayName> 
      <Protocol Name="OAuth2" /> 
      <Metadata> 
      <Item Key="ProviderName">github</Item> 
      <Item Key="authorization_endpoint">https://github.com/login/oauth/authorize</Item> 
      <Item Key="AccessTokenEndpoint">https://github.com/login/oauth/access_token?</Item> 
      <Item Key="HttpBinding">POST</Item> 
      <Item Key="ClaimsEndpoint">https://api.github.com/user</Item> 
      <Item Key="client_id">My Client Id</Item> 
      <Item Key="UsePolicyInRedirectUri">0</Item> 
      <Item Key="scope">user</Item> 
      <Item Key="response_types">code</Item> 
      </Metadata> 
      <CryptographicKeys> 
      <Key Id="client_secret" StorageReferenceId="B2C_1A_GitHubSecret" /> 
      </CryptographicKeys> 
      <OutputClaims> 
      <OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="id" /> 
      <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="email" /> 
      <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" /> 
      <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="github.com" /> 
      <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" /> 
      </OutputClaims> 
      <OutputClaimsTransformations> 
      <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" /> 
      <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" /> 
      <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" /> 
      </OutputClaimsTransformations> 
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" /> 
     </TechnicalProfile> 
     </TechnicalProfiles> 
    </ClaimsProvider> 

問題がaccess_tokenはをJSONで返されていないということですかしら?私は郵便配達のステップ自分のすべてを強化し、コードがURLパラメータとして返された、とaccess_tokenは、このようなレスポンスのボディに戻されました:

access_token=<snip>&scope=user%3Aemail&token_type=bearer 

私は、メタデータ項目をしないのですこの応答をサポートするカスタムプロバイダですか?またはこれはAzure AD B2Cでは機能しませんか?

答えて

0

はい、アクセストークンの応答がJSONではなくHTML形式でエンコードされているためです。

以下はGitHubとの統合方法です。 AzureのADのB2Cソーシャルユーザ識別子にタイプlongのGitHubのユーザ識別子から変換するためのクレーム変換を追加)

<ClaimType Id="gitHubUserId"> 
    <DisplayName>GitHub User ID</DisplayName> 
    <DataType>long</DataType> 
</ClaimType> 

2:

1)タイプlongのGitHubのユーザ識別子のためのクレームの種類を追加タイプstringの:

<ClaimsTransformation Id="CreateAlternativeSecurityUserIdForGitHub" TransformationMethod="ConvertNumberToStringClaim"> 
    <InputClaims> 
    <InputClaim ClaimTypeReferenceId="gitHubUserId" TransformationClaimType="inputClaim" /> 
    </InputClaims> 
    <InputParameters> 
    <InputParameter Id="stringFormat" DataType="string" Value="{0}" /> 
    </InputParameters> 
    <OutputClaims> 
    <OutputClaim ClaimTypeReferenceId="socialIdpUserId" TransformationClaimType="outputClaim" /> 
    </OutputClaims> 
</ClaimsTransformation> 

3)GitHubのOAuthのフローのための技術的なプロファイルを追加します。

0123を
+0

クリス、応答に感謝します!私はアプリの洞察で、クレームの返答がGitHubから戻ってくるのを見ることができますが、それでもValidateApiResponseHandlerフェーズ中に内部サーバエラーが発生しています(そして、エラーを返す前にNoOpHandlerに移動します): "A self-理由が「内部サーバーエラー」で応答が失敗しました。 私は元のポリシー名をUserAgentForClaimsExchangeフィールドに置きます:CPIM-Basic//B2C_1A_signup_signin。それは参照する正しい方針ですか? –

+0

UserAgentForClaimsExchangeとは何ですか? –

+0

{tenant}トークンまたは{policy}トークンを置き換えないでください。 Azure AD B2Cエンジンがそれらを置き換えます。 –

関連する問題