Skip to content

Commit 23d25dd

Browse files
authored
Merge pull request #229426 from MicrosoftDocs/main
3/03 AM Publish
2 parents a7e0f2f + ae59ba8 commit 23d25dd

File tree

96 files changed

+652
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+652
-431
lines changed

articles/active-directory-b2c/add-api-connector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Content-type: application/json
331331
{
332332
"version": "1.0.0",
333333
"action": "ShowBlockPage",
334-
"userMessage": "There was a problem with your request. You are not able to sign up at this time.",
334+
"userMessage": "There was a problem with your request. You are not able to sign up at this time. Please contact your system administrator",
335335
}
336336
337337
```

articles/active-directory-b2c/add-sign-up-and-sign-in-policy.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Watch this video to learn how the user sign-up and sign-in policy works.
3737
3838
## Prerequisites
3939

40-
[!INCLUDE [active-directory-b2c-customization-prerequisites](../../includes/active-directory-b2c-customization-prerequisites.md)]
40+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
41+
- If you don't have one already, [create an Azure AD B2C tenant](tutorial-create-tenant.md) that is linked to your Azure subscription.
4142

4243
::: zone pivot="b2c-user-flow"
4344

articles/active-directory-b2c/configure-authentication-sample-python-web-app.md

Lines changed: 36 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: CelesteDG
77
ms.service: active-directory
88
ms.workload: identity
99
ms.topic: reference
10-
ms.date: 06/28/2022
10+
ms.date: 02/28/2023
1111
ms.author: kengaderdus
1212
ms.subservice: B2C
1313
ms.custom: "b2c-support"
@@ -19,7 +19,7 @@ This article uses a sample Python web application to illustrate how to add Azure
1919

2020
## Overview
2121

22-
OpenID Connect (OIDC) is an authentication protocol that's built on OAuth 2.0. You can use OIDC to securely sign users in to an application. This web app sample uses the [Microsoft Authentication Library (MSAL) for Python](https://github.com/AzureAD/microsoft-authentication-library-for-python). The MSAL for Python simplifies adding authentication and authorization support to Python web apps.
22+
OpenID Connect (OIDC) is an authentication protocol that's built on OAuth 2.0. You can use OIDC to securely sign users in to an application. This web app sample uses the [identity package for Python](https://pypi.org/project/identity/) to simplify adding authentication and authorization support to Python web apps.
2323

2424
The sign-in flow involves the following steps:
2525

@@ -29,17 +29,11 @@ The sign-in flow involves the following steps:
2929
1. After users sign in successfully, Azure AD B2C returns an ID token to the app.
3030
1. The app exchanges the authorization code with an ID token, validates the ID token, reads the claims, and then returns a secure page to users.
3131

32-
33-
### Sign-out
34-
35-
[!INCLUDE [active-directory-b2c-app-integration-sign-out-flow](../../includes/active-directory-b2c-app-integration-sign-out-flow.md)]
36-
3732
## Prerequisites
3833

39-
A computer that's running:
40-
41-
* [Visual Studio Code](https://code.visualstudio.com/) or another code editor
42-
* [Python](https://www.python.org/downloads/) 3.9 or above
34+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
35+
- If you don't have one already, [create an Azure AD B2C tenant](tutorial-create-tenant.md) that is linked to your Azure subscription.
36+
- [Python 3.7+](https://www.python.org/downloads/)
4337

4438
## Step 1: Configure your user flow
4539

@@ -90,37 +84,29 @@ Extract the sample file to a folder where the total length of the path is 260 or
9084
In the project's root directory, follow these steps:
9185

9286
1. Rename the *app_config.py* file to *app_config.py.OLD*.
93-
1. Rename the *app_config_b2c.py* file to *app_config.py*.
94-
95-
Open the *app_config.py* file. This file contains information about your Azure AD B2C identity provider. Update the following app settings properties:
96-
97-
|Key |Value |
98-
|---------|---------|
99-
|`b2c_tenant`| The first part of your Azure AD B2C [tenant name]( tenant-management-read-tenant-name.md#get-your-tenant-name) (for example, `contoso`).|
100-
|`CLIENT_ID`| The web API application ID from [step 2.1](#step-21-register-the-app).|
101-
|`CLIENT_SECRET`| The client secret value you created in [step 2.2](#step-22-create-a-web-app-client-secret). To help increase security, consider storing it instead in an environment variable, as recommended in the comments. |
102-
|`*_user_flow`|The user flows or custom policy you created in [step 1](#step-1-configure-your-user-flow).|
103-
| | |
104-
105-
Your final configuration file should look like the following Python code:
106-
107-
```python
108-
import os
109-
110-
b2c_tenant = "contoso"
111-
signupsignin_user_flow = "B2C_1_signupsignin"
112-
editprofile_user_flow = "B2C_1_profileediting"
113-
resetpassword_user_flow = "B2C_1_passwordreset"
114-
authority_template = "https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{user_flow}"
115-
116-
CLIENT_ID = "11111111-1111-1111-1111-111111111111" # Application (client) ID of app registration
117-
118-
CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxx" # Placeholder - for use ONLY during testing.
119-
```
87+
1. Rename the *app_config_b2c.py* file to *app_config.py*. This file contains information about your Azure AD B2C identity provider.
88+
89+
1. Create an `.env` file in the root folder of the project using `.env.sample.b2c` as a guide.
90+
91+
```shell
92+
FLASK_DEBUG=True
93+
TENANT_NAME=<tenant name>
94+
CLIENT_ID=<client id>
95+
CLIENT_SECRET=<client secret>
96+
SIGNUPSIGNIN_USER_FLOW=B2C_1_profile_editing
97+
EDITPROFILE_USER_FLOW=B2C_1_reset_password
98+
RESETPASSWORD_USER_FLOW=B2C_1_signupsignin1
99+
```
120100

121-
> [!IMPORTANT]
122-
> As noted in the code snippet comments, we recommend that you *do not store secrets in plaintext* in your application code. The hard-coded variable is used in the code sample *for convenience only*. Consider using an environment variable or a secret store, such as an Azure key vault.
101+
|Key |Value |
102+
|---------|---------|
103+
|`TENANT_NAME`| The first part of your Azure AD B2C [tenant name](tenant-management-read-tenant-name.md#get-your-tenant-name) (for example, `contoso`). |
104+
|`CLIENT_ID`| The web API application ID from [step 2.1](#step-21-register-the-app).|
105+
|`CLIENT_SECRET`| The client secret value you created in [step 2.2](#step-22-create-a-web-app-client-secret). |
106+
|`*_USER_FLOW`|The user flows you created in [step 1](#step-1-configure-your-user-flow).|
107+
| | |
123108

109+
The environment variables are referenced in *app_config.py*, and are kept in a separate *.env* file to keep them out of source control. The provided *.gitignore* file prevents the *.env* file from being checked in.
124110

125111
## Step 5: Run the sample web app
126112

@@ -157,11 +143,9 @@ CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxx" # Placeholder - for use ONLY during t
157143
The console window displays the port number of the locally running application:
158144

159145
```console
160-
* Serving Flask app "app" (lazy loading)
161-
* Environment: production
146+
* Debug mode: on
162147
WARNING: This is a development server. Do not use it in a production deployment.
163148
Use a production WSGI server instead.
164-
* Debug mode: off
165149
* Running on `http://localhost:5000/` (Press CTRL+C to quit)
166150
```
167151

@@ -190,7 +174,7 @@ To enable your app to sign in with Azure AD B2C and call a web API, you must reg
190174

191175
The app registrations and the application architecture are described in the following diagrams:
192176

193-
![Diagram describing a web app with web A P I, registrations, and tokens.](./media/configure-authentication-sample-python-web-app/web-app-with-api-architecture.png)
177+
![Diagram describing a web app with web API, registrations, and tokens.](./media/configure-authentication-sample-python-web-app/web-app-with-api-architecture.png)
194178

195179
[!INCLUDE [active-directory-b2c-app-integration-call-api](../../includes/active-directory-b2c-app-integration-call-api.md)]
196180

@@ -208,58 +192,34 @@ The app registrations and the application architecture are described in the foll
208192

209193
### Step 6.4: Configure your web API
210194

211-
This sample acquires an access token with the relevant scopes, which the web app can use for a web API. To call a web API from the code, use an existing web API or create a new one. For more information, see [Enable authentication in your own web API by using Azure AD B2C](enable-authentication-web-api.md).
195+
This sample acquires an access token with the relevant scopes, which the web app can use for a web API. This sample itself does *not* act as a web API. Instead, you must use an existing web API or create a new one. For a tutorial on creating a web API in your B2C tenant, see [Enable authentication in your own web API by using Azure AD B2C](enable-authentication-web-api.md).
212196

213197
### Step 6.5: Configure the sample app with the web API
214198

215199
Open the *app_config.py* file. This file contains information about your Azure AD B2C identity provider. Update the following properties of the app settings:
216200

217201
|Key |Value |
218202
|---------|---------|
219-
|`ENDPOINT`| The URI of your web API (for example, `https://localhost:5000/getAToken`).|
220-
|`SCOPE`| The web API [scopes](#step-62-configure-scopes) that you created.|
203+
|`ENDPOINT`| The URI of your web API (for example, `https://localhost:6000/hello`).|
204+
|`SCOPE`| The web API [scopes](#step-62-configure-scopes) that you created (for example, `["https://contoso.onmicrosoft.com/tasks-api/tasks.read", https://contoso.onmicrosoft.com/tasks-api/tasks.write"]`).|
221205
| | |
222206

223-
Your final configuration file should look like the following Python code:
224-
225-
```python
226-
import os
227-
228-
b2c_tenant = "contoso"
229-
signupsignin_user_flow = "B2C_1_signupsignin"
230-
editprofile_user_flow = "B2C_1_profileediting"
231-
resetpassword_user_flow = "B2C_1_passwordreset"
232-
authority_template = "https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{user_flow}"
233-
234-
CLIENT_ID = "11111111-1111-1111-1111-111111111111" # Application (client) ID of app registration
235-
236-
CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxx" # Placeholder - for use ONLY during testing.
237-
238-
### More code here
239-
240-
# This is the API resource endpoint
241-
ENDPOINT = 'https://localhost:5000'
242-
243-
244-
SCOPE = ["https://contoso.onmicrosoft.com/api/demo.read", "https://contoso.onmicrosoft.com/api/demo.write"]
245-
```
246-
247207
### Step 6.6: Run the sample app
248208

249209
1. In your console or terminal, switch to the directory that contains the sample.
250-
1. Stop the app. and then rerun it.
251-
1. Select **Call Microsoft Graph API**.
210+
1. If the app isn't still running, restart it using the command from Step 5.
211+
1. Select **Call a downstream API**.
252212
253-
![Screenshot showing how to call a web A P I.](./media/configure-authentication-sample-python-web-app/call-web-api.png)
213+
![Screenshot showing how to call a web API.](./media/configure-authentication-sample-python-web-app/call-web-api.png)
254214
255215
## Step 7: Deploy your application
256216
257217
In a production application, the app registration redirect URI is ordinarily a publicly accessible endpoint where your app is running, such as `https://contoso.com/getAToken`.
258218
259219
You can add and modify redirect URIs in your registered applications at any time. The following restrictions apply to redirect URIs:
260220
261-
* The reply URL must begin with the scheme `https`.
262-
* The reply URL is case-sensitive. Its case must match the case of the URL path of your running application.
221+
* The redirect URL must begin with the scheme `https`.
222+
* The redirect URL is case-sensitive. Its case must match the case of the URL path of your running application.
263223
264224
## Next steps
265225
* Learn how to [Configure authentication options in a Python web app by using Azure AD B2C](enable-authentication-python-web-app-options.md).
5.4 KB
Loading
-4.52 KB
Loading

0 commit comments

Comments
 (0)