Skip to content

Commit 4e9ffa1

Browse files
authored
Merge pull request #230408 from yoelhor/patch-333
[Azure AD B2C] pass IDP refresh token
2 parents cfe2a3d + b6fe9cd commit 4e9ffa1

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

articles/active-directory-b2c/idp-pass-through-user-flow.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: CelesteDG
99
ms.service: active-directory
1010
ms.workload: identity
1111
ms.topic: how-to
12-
ms.date: 03/10/2022
12+
ms.date: 03/16/2023
1313
ms.custom: project-no-code
1414
ms.author: kengaderdus
1515
ms.subservice: B2C
@@ -150,6 +150,77 @@ When testing your applications in Azure AD B2C, it can be useful to have the Azu
150150

151151
![Decoded token in jwt.ms with idp_access_token block highlighted](./media/idp-pass-through-user-flow/identity-provider-pass-through-token-custom.png)
152152

153+
## Pass the IDP refresh token (optional)
154+
155+
The access token the identity provider returns is valid for a short period of time. Some identity providers also issue a refresh token along with the access token. Your client application can then exchange the identity provider's refresh token for a new access token when needed.
156+
157+
Azure AD B2C custom policy supports passing the refresh token of OAuth 2.0 identity providers, which includes [Facebook](https://github.com/azure-ad-b2c/unit-tests/tree/main/Identity-providers#facebook-with-access-token), [Google](https://github.com/azure-ad-b2c/unit-tests/tree/main/Identity-providers#facebook-with-access-token) and [GitHub](https://github.com/azure-ad-b2c/unit-tests/tree/main/Identity-providers#github-with-access-token).
158+
159+
To pass the identity provider's refresh token, follow these steps:
160+
161+
1. Open your *TrustframeworkExtensions.xml* file and add the following **ClaimType** element with an identifier of `identityProviderRefreshToken` to the **ClaimsSchema** element.
162+
163+
```xml
164+
<ClaimType Id="identityProviderRefreshToken">
165+
<DisplayName>Identity provider refresh token</DisplayName>
166+
<DataType>string</DataType>
167+
</ClaimType>
168+
```
169+
170+
1. Add the **OutputClaim** element to the **TechnicalProfile** element for each OAuth 2.0 identity provider that you would like the refresh token for. The following example shows the element added to the Facebook technical profile:
171+
172+
```xml
173+
<ClaimsProvider>
174+
<DisplayName>Facebook</DisplayName>
175+
<TechnicalProfiles>
176+
<TechnicalProfile Id="Facebook-OAUTH">
177+
<OutputClaims>
178+
<OutputClaim ClaimTypeReferenceId="identityProviderRefreshToken" PartnerClaimType="{oauth2:refresh_token}" />
179+
</OutputClaims>
180+
...
181+
</TechnicalProfile>
182+
</TechnicalProfiles>
183+
</ClaimsProvider>
184+
```
185+
186+
1. Some identity providers require you to include metadata or scopes to the identity provider's technical profile.
187+
188+
- For Google identity provider, add two claim types `access_type` and `prompt`. Then add the following input claims to the identity provider's technical profile:
189+
190+
```xml
191+
<InputClaims>
192+
<InputClaim ClaimTypeReferenceId="access_type" PartnerClaimType="access_type" DefaultValue="offline" AlwaysUseDefaultValue="true" />
193+
194+
<!-- The refresh_token is return only on the first authorization for a given user. Subsequent authorization request doesn't return the refresh_token.
195+
To fix this issue we add the prompt=consent query string parameter to the authorization request-->
196+
<InputClaim ClaimTypeReferenceId="prompt" PartnerClaimType="prompt" DefaultValue="consent" AlwaysUseDefaultValue="true" />
197+
</InputClaims>
198+
```
199+
200+
- Other identity providers may have different methods to issue a refresh token. Follow the identity provider's audience and add the necessary elements to your identity provider's technical profile.
201+
202+
1. Save the changes you made in your *TrustframeworkExtensions.xml* file.
203+
1. Open your relying party policy file, such as *SignUpOrSignIn.xml*, and add the **OutputClaim** element to the **TechnicalProfile**:
204+
205+
```xml
206+
<RelyingParty>
207+
<DefaultUserJourney ReferenceId="SignUpOrSignIn" />
208+
<TechnicalProfile Id="PolicyProfile">
209+
<OutputClaims>
210+
<OutputClaim ClaimTypeReferenceId="identityProviderRefreshToken" PartnerClaimType="idp_refresh_token"/>
211+
</OutputClaims>
212+
...
213+
</TechnicalProfile>
214+
</RelyingParty>
215+
```
216+
217+
1. Save the changes you made in your policy's relying party policy file.
218+
1. Upload the *TrustframeworkExtensions.xml* file, and then the relying party policy file.
219+
1. [Test your policy](#test-your-policy)
220+
221+
222+
223+
153224
::: zone-end
154225

155226
## Next steps

0 commit comments

Comments
 (0)