- Create an Azure AD B2C Directory
- Create a Regular Web Application (set the url here to https://YOUR_AUTH0_ACCOUNT/login/callback)
- Create a key
- Take note of the Application ID and the Key
- Create a sign in policy (you will have a name like
B2C_1_signing
)
Replace in the following:
YOUR_AUTH0_DOMAIN
: Your domain, like sandrino.auth0.comYOUR_DIRECTORY_NAME
: The name of your Azure AD B2C DirectoryYOUR_APPLICATION_ID
: The Application ID of your Regular Web Application in the Azure PortalYOUR_APPLICATION_KEY
: The key you created in the Azure PortalYOUR_POLICY_NAME
: Replace this with the name of your policy (B2C_1_signin for example)enabled_clients
: Replace these with the identifiers of the clients in Auth0 for which you want to enable this.
POST https://YOUR_AUTH0_DOMAIN/api/v2/connections
{
"options": {
"client_id": "YOUR_APPLICATION_ID",
"client_secret": "YOUR_APPLICATION_KEY",
"scripts": {
"fetchUserProfile": "function(accessToken, ctx, cb) {\n const jwt = require('jsonwebtoken');\n const decoded = jwt.decode(ctx.id_token);\n cb(null, {\n user_id: decoded.sub,\n family_name: decoded.family_name,\n given_name: decoded.given_name,\n name: decoded.name,\n email: decoded.email\n });\n}"
},
"authorizationURL": "https://login.microsoftonline.com/YOUR_DIRECTORY_NAME.onmicrosoft.com/oauth2/v2.0/authorize",
"tokenURL": "https://login.microsoftonline.com/YOUR_DIRECTORY_NAME.onmicrosoft.com/oauth2/v2.0/token?p=YOUR_POLICY_NAME",
"scope": "openid profile",
"authParams": { "p": "YOUR_POLICY_NAME" }
},
"strategy": "oauth2",
"name": "AzureAD-B2C",
"enabled_clients": [
"H70hUtVwUxpL9QwQSdsD9Jfq27gHZJir",
"IsTxQ7jAYAXL5r5HM4L1RMzsSG0UHeOy",
"aVefdrhGdyAijkxQaSnhVKGhWtgXq58B",
"htxj4gBowcGcy2kYgbRqdUH9cFJ9dseU",
"jZYOy5Pyv6ZcbG0rhsOKyAmBnNoINO3u",
"w8yGQ7r7vtQGZ00RrD0I45mMVjFmO8st"
]
}
You can login here with [email protected]
/ Mypassword1
Hi there Sandrina!
Thank you so much for posting this. I was wondering if you could share any of your configuration on the azure custom policy that you created for b2c which interfaces with this configuration? Or if anyone else has any other clarification to provide. I am trying to set up a B2C app which is connected directly to an auth0 account.