Msal.js not authenticating with google - Redirect uri issue

379 Views Asked by At

So I recently used the quickstart method from Azure to make a JS app which authenticates using the MSAL.js library. I am able to authenticate using the normal users in AD, however when adding in google as an external identity provider, I get the Authorization error: "Error 400: redirect_uri_mismatch The redirect URI in the request, https://login.microsoftonline.com/te/{tenant-id}/oauth2/authresp, does not match the ones authorized for the OAuth client...."

I have checked the URI in my JS app, on Azure and added it in the Google develops console to no avail. I have followed the documentation as per: https://learn.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-google

I have tried fiddling with everything and don't know what to do to fix it. Keep in mind that when I created the Azure account, it automatically made my tenant name "Default directory" and my Primary domain as "{FirstName}{EmailDomain}@onmicrosoft.com". I since then change my tenant name to "NewTenant" (I will be changing all names for the purpose of this question as I would like to not reveal any actual details where possible).

To conceal my details I'll be making "{FirstName}": "Bob", and "{EmailDomain}": "mydomain"

JS code:

      const msalConfig = {
        auth: {
          clientId: '{ClientId}', 
          authority: 'https://login.microsoftonline.com/{TenantId}',
          domain: 'bobmydomain.onmicrosoft.com',
          instance: 'https://bobmydomain.b2clogin.com/tfp',
          redirectUri: "http://localhost:3000/"
        },
        cache: {
          cacheLocation: 'sessionStorage',
          storeAuthStateInCookie: false
        }
      };

Azure: Azure redirect URIs

Google developer console: Google redirect URIs Bear in mind I fiddled with the HTML so that I could get a nice screenshot. I have also configured the ClientID and ClientSecret for Google auth in the Azure external identity provider portal. EDIT: http://localhost:3000/ was also added as a redirect URI to the Google dev console but also to no avail

Any help would be appreciated.

0

There are 0 best solutions below