azure-ad-b2cazure-api-managementapim

Server error occured while using B2C on Azure API Management Develop portal


I want to add the ability to sign in or up for my APIM developer portal via any Microsoft account type (personal or corporate, work ...).

I have uploaded SocialAndLocalAccounts custom policy from the starter pack (removed the Facebook provider and added AADCommon-OpenIdConnect) - I have attached these files below.

I have errors while I'm trying to sign up via a local or Microsoft account.

Let's try to look Microsoft account (multitenant)

  1. Click "Multi-Tenant ADD" button enter image description here

  2. When you filled the email and password, you will be redirected to webPortal.com/signup-oauth#provider=AadB2C&token=eyJhbGciOiJSUzI1NiIsImtpZ... enter image description here

  3. Looks like, all is good except that we have lost the session, and when we press "sign up" button, we get an exception: enter image description here

  4. the JWT token enter image description here

Similar behavior I have when I try to sign up via a local account, but on the first step - record with user created in b2c tenant and then we can sign in by login and password:

  1. When I filled email and password and confirmed email address, this one error, and 401 error code for "/identity", and 403 for "/users" endpoints .

    • The requests to Users and Identity have a header: Authorization: AadB2C id_token="eyJhbGciOiJSUzI1NiIsImtpZC....." enter image description here
  2. When I try to click "Microsoft Account" again - server redirects me to this one page: enter image description here

  3. The jwt from the local account is this one: enter image description here

So, Azure Active Directory B2C tenant has:

APIM Developer portal tenant has:

For this task, I am using these tutorials:

https://learn.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-user-flows?pivots=b2c-custom-policy (from 1 to 3 tutorials)

https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-aad-b2c

https://learn.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-azure-ad-multi-tenant?pivots=b2c-custom-policy

Here I have left custom policies that I'm using - https://drive.google.com/drive/folders/1F1uBgF1R96dTUVziNOrw2WTH6dd_xCUH?usp=sharing

I have no idea what happened and why I have faced these issues, could you please assist me with this issue?

I'm looking forward to any ideas and solutions.

Thank you in advance!


Solution

  • I'm glad to inform you that I have fixed this issue.

    In my case: I have changed to ADAL library and missed a claim (oid).

    User’s ObjectID(oid) and Subject(sub) claims in AADB2C token are necessary for APIM to identify the caller of APIM user creation call from developer portal. Lacking either of these two claims will cause AccessDenied issue.