私はカスタムポリシーを使用して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では機能しませんか?
クリス、応答に感謝します!私はアプリの洞察で、クレームの返答がGitHubから戻ってくるのを見ることができますが、それでもValidateApiResponseHandlerフェーズ中に内部サーバエラーが発生しています(そして、エラーを返す前にNoOpHandlerに移動します): "A self-理由が「内部サーバーエラー」で応答が失敗しました。 私は元のポリシー名をUserAgentForClaimsExchangeフィールドに置きます:CPIM-Basic//B2C_1A_signup_signin。それは参照する正しい方針ですか? –
UserAgentForClaimsExchangeとは何ですか? –
{tenant}トークンまたは{policy}トークンを置き換えないでください。 Azure AD B2Cエンジンがそれらを置き換えます。 –