You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Switch to using the tenant domain name for the tenant ID in [config.js](config.js).
6
+
* Update README to reflect current state of sample and the articles referenced on [docs.microsoft.com](https://docs.microsoft.com/azure/active-directory-b2c).
This sample demonstrates how to protect a Node.js web API with Azure AD B2C using the Passport.js library. The code here is pre-configured with a registered client ID. If you register your own app, you will need to replace the client ID.
15
+
This sample demonstrates how to protect a Node.js web API with Azure AD B2C using the Passport.js library. The code here is pre-configured with a registered client ID. If you register your own app, replace the client ID.
16
16
17
17
To see how to call this web API from a client application, refer to this [B2C Single Page Application sample](https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp).
2.Install [Node.js](https://nodejs.org/en/download/) if you don't already have it.
44
44
45
-
3. Install the node dependencies:
45
+
3. Install the Node dependencies:
46
46
47
47
```console
48
48
npm install && npm update
49
49
```
50
50
51
-
4. Run the Web API! By default it will run on `http://localhost:5000`
51
+
4. Run the Web API. By default, it runs on `http://localhost:5000`
52
52
53
53
```console
54
54
npm start
55
55
```
56
56
57
-
## Next Steps
57
+
## Using your own Azure AD B2C tenant
58
58
59
-
### Using your own Azure AD B2C Tenant
59
+
To have a proper understanding of Azure AD B2C as a developer, follow the tutorials in the official [Azure AD B2C documentation](https://docs.microsoft.com/azure/active-directory-b2c/). In the rest of this guide, we summarize the steps you need to go through.
60
60
61
-
To have a proper understanding of Azure AD B2C as a developer, follow the tutorials on Azure [AD B2C documentation](https://docs.microsoft.com/en-us/azure/active-directory-b2c/). In the rest of this guide, we summarize the steps you need to go through.
61
+
### Step 1: Get your own Azure AD B2C tenant
62
62
63
-
#### Step 1: Get your own Azure AD B2C Tenant
63
+
You first need an Azure AD B2C tenant. If you don't already have one you can use for testing purposes, create your own by following the steps in [Tutorial: Create an Azure Active Directory B2C tenant](https://docs.microsoft.com/azure/active-directory-b2c/tutorial-create-tenant).
64
64
65
-
First, you'll need an Azure AD B2C tenant. If you don't have an existing Azure AD B2C tenant that you can use for testing purposes, you can create your own by following [these instructions](https://azure.microsoft.com/documentation/articles/active-directory-b2c-get-started).
65
+
### Step 2: Create your own policies
66
66
67
-
#### Step 2: Create your own policies
67
+
This sample uses a unified sign-up/sign-in policy. You can create [your own unified sign-up/sign-in policy](https://docs.microsoft.com/azure/active-directory-b2c/tutorial-create-user-flows). You may choose to include as many or as few identity providers as you wish.
68
68
69
-
This sample uses a unified sign-up/sign-in policy. You can create [your own unified sign-up/sign-in policy](https://azure.microsoft.com/documentation/articles/active-directory-b2c-reference-policies). You may choose to include as many or as few identity providers as you wish.
70
-
71
-
If you already have existing policies in your Azure AD B2C tenant, feel free to re-use those policies in this sample.
69
+
If you already have existing policies in your Azure AD B2C tenant, feel free to reuse those policies in this sample.
72
70
73
71
#### Step 3: Register your own web API with Azure AD B2C
74
72
75
-
Follow the instructions at [register a Web API with Azure AD B2C](https://docs.microsoft.com/en-us/azure/active-directory-b2c/add-web-application?tabs=applications) to register the Node.js Web API sample with your tenant. Registering your Web API allows you to define the scopes that your singlepage application will request access tokens for.
73
+
Follow the steps in [Protect and grant access to a Node.js web API](https://docs.microsoft.com/azure/active-directory-b2c/tutorial-single-page-app-webapi) to register the web API application in your tenant, define scopes, and grant a web application access to the API. By following the steps in the tutorial, you define the scopes that your single-page application will request access tokens for.
76
74
77
75
#### Step 4: Configure your application source code
78
76
79
-
You can now fill in the variables in the `config.js` file of the Node.js Web API sample with the parameters you've obtained from the Azure Portal during the steps above.
77
+
You can now fill in the variables in the *config.js* file of the Node.js web API sample with the parameters you've obtained from the Azure portal by following the steps above.
80
78
81
79
Configure the following variables:
82
80
83
81
```javascript
84
-
constclientID="<Application ID for your Node.js Web API - found on Properties page in Azure portal e.g. 93733604-cc77-4a3c-a604-87084dd55348>";
85
-
constb2cDomainHost="<Domain of your B2C host eg. fabrikamb2c.b2clogin.com>";
86
-
consttenantIdGuid="<Application ID for your Node.js Web API - found on Properties page in Azure portal e.g. 775527ff-9a37-4307-8b3d-cc311f58d925>";
87
-
constpolicyName="<Name of your sign in / sign up policy, e.g. B2C_1_SUSI>";
82
+
constclientID="<Application (client) ID of your Node.js web API, e.g. 93733604-0000-0000-0000-87084dd55348>"
83
+
constb2cDomainHost="<Domain name of your B2C authority, e.g. fabrikamb2c.b2clogin.com>";
84
+
consttenantId="<Domain name of your B2C tenant, e.g. fabrikamb2c.onmicrosoft.com>";
85
+
constpolicyName="<Name of your sign in / sign up policy. Example: B2C_1_SUSI>";
88
86
```
89
87
90
88
> **NOTE**
91
89
>
92
-
>Developers using the [Azure China Environment](https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-national-cloud), MUST use <your-tenant-name>.b2clogin.cn authority, instead of `login.chinacloudapi.cn`.
90
+
>Developers using the [Azure China](https://docs.microsoft.com/azure/active-directory/develop/authentication-national-cloud) environment MUST use `<your-tenant-name>.b2clogin.cn` authority instead of `login.chinacloudapi.cn`.
93
91
>
94
-
> In order to use <your-tenant-name>.b2clogin.*, you will need to configure you application and set `validateAuthority: false`. Learn more about using [b2clogin](https://docs.microsoft.com/en-us/azure/active-directory-b2c/b2clogin#set-the-validateauthority-property).
92
+
> To use `<your-tenant-name>.b2clogin.*`, you need set `validateIssuer: false`. Learn more about using [b2clogin.com](https://docs.microsoft.com/azure/active-directory-b2c/b2clogin).
93
+
94
+
### Step 5: Run the application
95
95
96
-
Lastly, to run your Node.js Web API, run the following command from your shell or command line
96
+
Lastly, to run your Node.js Web API, execute the following commands in your shell or terminal:
97
97
98
98
```bash
99
99
npm install && npm update
100
100
npm start
101
101
```
102
102
103
-
Your Node.js Web API sample is now running on Port 5000.
103
+
Your Node.js web API is now running on port 5000.
104
104
105
-
## Questions & Issues
105
+
## Questions & issues
106
106
107
-
Please file any questions or problems with the sample as a GitHub issue. You can also post on Stack Overflow with the tag `azure-ad-b2c`. For OAuth2.0 library issues, please see note below.
107
+
Please file any questions or problems with the sample as a GitHub issue. You can also post on Stack Overflow with the tag `azure-ad-b2c`.
108
108
109
109
## Contributing
110
110
111
-
If you'd like to contribute to this sample, see [CONTRIBUTING.MD](./CONTRIBUTING.md).
111
+
If you'd like to contribute to this sample, see [CONTRIBUTING.md](./CONTRIBUTING.md).
112
112
113
-
## Code of Conduct
113
+
## Code of conduct
114
114
115
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
116
-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
117
-
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
115
+
For details, see [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
0 commit comments