azureazure-ad-b2cmicrosoft-entra-id

Authenticating with Azure AD B2C Issue


I previously had this setup and working with my NextJs app using NextAuth, but I think the creds expired. So when I create a new Client Secret key and Client ID I figured I would update my app then it would be good to go, but that was not the case. I am getting an error saying the Client Id is not registered to the tenant, but from what I can tell it is. Error

The app is registered and all the flows and permissions have been setup.

Anyone know what I am doing wrong, Im not an Azure expert so its just not making sense. App Registered


Solution

  • Based on the screenshot you provided it seems like you are passing invalid ClientID that is you are passing ClientSecret in the place of ClientID.

    The error "AADB2C90018:The client id XXX specified in the request is not registered in the tenant" usually occurs if you are passing invalid client id or if the application is not created in the tenant.

    Initially I got the same error when I passed ClientSecret in the request:

    enter image description here

    Hence to resolve the error, make sure to pass the valid ClientID in the request.

    enter image description here

    When I passed the valid ClientID, I am able to login to the application:

    https://b2c.b2clogin.com/b2c.onmicrosoft.com/B2C_1_testruk/oauth2/v2.0/authorize?
    &client_id=ClientID
    &response_type=code
    &redirect_uri=https://jwt.ms
    &response_mode=query
    &scope=https://graph.microsoft.com/.default
    &state=12345
    

    enter image description here

    Hence pass correct values for ClientID and ClientSecret in the code to resolve the error.