Auth0 SDK js saml login

Hi, I’m new to auth0.

I have a question about auth0 saml login.

The target:
I want to build a SPA using auth0 as IdP and connect to 2 applications. The first app is an API to consume an auth0 management API. The second will consume an Azure resource using Azure B2C.

I use the example auth0’s quick start vue js example code as the base to start the trial. The app to consume auth0 works. I’m now trying to log in to Azure B2C.

Current status:
Azure side:

  • setup application
  • Config user flow
  • The user flow test works as expected to open the auth0 universal login window and allow users to log in using the U/P store in the auth0 database. A new user can be created in B2C directory

auth0 side:

  • In the application configured for app1, set saml addon

Question:
How can I reuse the user flow in the existing vue js example code to login to the second app? Or in another way, how can I achieve SSO based on the example code?

Should I make any changes to the auth0 instance initialization code here?

app
  .use(router)
  .use(
    createAuth0({
      domain: import.meta.env.VITE_AUTH0_DOMAIN,
      clientId: import.meta.env.VITE_AUTH0_CLIENT_ID,
      authorizationParams: {
        audience: import.meta.env.VITE_AUTH0_AUDIENCE,
        redirect_uri: import.meta.env.VITE_AUTH0_CALLBACK_URL,
      },
    }) 
  )

I want to change the code below to use the access token issued by B2C to consume the resource from Azure. What changes should I make?

const getMessage = async () => {
  const { getAccessTokenSilently} = useAuth0();
  const accessToken = await getAccessTokenSilently();
  const { data, error } = await getProtectedResource(accessToken);

  if (data) {
    message.value = JSON.stringify(data, null, 2);
  }

  if (error) {
    message.value = JSON.stringify(error, null, 2);
  }
};

Thanks in advance!

Hi @henry.qin

Welcome to the Auth0 Community!

Just to confirm; you are trying to access some Azure resource, and to do so, you will need to get an Azure access token.

Generally, Identity Provider access tokens are available in the user’s profile in the management API, but some providers don’t make them available.

This doc shows you how to access those identity provider access tokens, please let me know if you have any questions.

Thanks Dan

I aim to use auth0 as an identity provider and Azure as the service provider. So, the user will log in using the auth0 universal login window.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.