Azure AD B2C - Error AADB2C90018 immediately after the app registration was created

Dumitru Pascu 1 Reputation point
2021-12-30T20:20:18.623+00:00

I have a multitenant application and I use Azure B2C as an identity provider. Each tenant has its own application registration (with different redirect URLs). The application registrations are created programmatically at tenant creation.

Immediately after the creation, Azure B2C gets the following error when I redirect an user to the login page:

AADB2C90018: The client id '<just-created-app-id>' specified in the request is not registered in tenant '<my-tenant>'. After few seconds, the same URL will work as expected. I assume the app registration creation is executed asynchronously by Azure B2C and eventually it is processed.

Question: how can I make sure that I don't redirect the user to Azure B2C before the new app registration is functional?

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,639 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,306 Reputation points
    2021-12-31T07:47:48.43+00:00

    Hi @Dumitru Pascu • Thank you for reaching out.

    The only option, as far as I can think of, is to configure your application to retry with exponential backoff upon receiving the AADB2C90018 error, as explained below:

    161605-image.png

    1. Application invokes the request that fails with the error AADB2C90018.
    2. Application waits for a short interval (e.g. 1 second) and tries again. The request still fails with the error AADB2C90018.
    3. Application waits for a longer interval (e.g. 2 seconds) and tries again. The request succeeds with HTTP response code 200 (OK).

    Code sample:

    {  
        Retry =  
        {  
            Delay= TimeSpan.FromSeconds(2),  
            MaxDelay = TimeSpan.FromSeconds(16),  
            MaxRetries = 5,  
            Mode = RetryMode.Exponential  
         }  
    };  
    
    # Wait 1 second, retry request  
    # If still fails wait 2 seconds, retry request  
    # If still fails wait 4 seconds, retry request  
    # If still fails wait 8 seconds, retry request  
    # If still fails wait 16 seconds, retry request  
    

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.