Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

527
Vistas
How to implement loginRedirect using vuejs and azureb2c and msal.js

I'm trying to implement an SSO using Azure b2c and Vuejs and MSAL, but I'm getting some issues.

msalConfig: {
      auth: {
        clientId: "******dd03",
        authority:"https://*****",
        knownAuthorities: [
          "******hb2cdev.onmicrosoft.com",
        ],
        redirectUri:'localhost:8080/#/main'
      },
      cache: {
       cacheLocation: "localStorage",
      },
     },
    accessToken: ""

component configuration :

    async created() {
     this.$msalInstance = new PublicClientApplication(
     this.authStore.$state.msalConfig
     );
   },

mounted() {
 console.log("msqlInstance :", this.$msalInstance);
 const accounts = this.$msalInstance.getAllAccounts();
 if (accounts.length == 0) {
  console.log("empty");
  return;
 }
 this.account = accounts[0];
 console.log("test :", this.account);
 this.$emitter.emit("login", this.account);
},

methods: {
  async SignIn() {
    console.log("test");
    await this.$msalInstance
    .loginPopup({})
    .then((res) => {
      const myAccounts = this.$msalInstance.getAllAccounts();
      this.account = myAccounts[0];
      this.$emitter.emit("login", this.account);
    })
    .catch((error) => {
      console.error(`error during authentication: ${error}`);
    });
},
async SignOut() {
  await this.$msalInstance
    .logout({})
    .then((res) => {
      this.$emitter.emit("logout", "logging out");
    })
    .catch((error) => {
      console.error(error);
    });
},
},

this code is working as expected but when I replace .loginPopup({}) on the Sign in method by loginRedirect to avoid having the popup I'm getting this error :

UserAuth.vue?212c:67 error during authentication: BrowserAuthError: interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API.
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To achieve the above requirement ,

First of all there are following prequisite we need in our environment;

  • An Azure Subscription

  • An Azure AD B2C Tenant/instance

  • Visual Studio Code

  • Vue.js

  • Node.js / NPM

  • .NET Core 3.1 or later (if you want to build and run the API)

  • TypeScript - yes, after popular demand, we used TS for this project

As you have already setup your environment , make sure that you have following in your .env file.

VUE_APP_MSAL_CLIENT_ID=<your client id>
VUE_APP_MSAL_LOGIN_AUTHORITY=https://<yourB2Cname>.b2clogin.com/<yourB2Cname>.onmicrosoft.com/<YourSignupSigninPolicyName>/
VUE_APP_MSAL_PASSWORD_RESET_AUTHORITY=https://<yourB2Cname>.b2clogin.com/<yourB2Cname>.onmicrosoft.com/<YourPasswordResetPolicy>/
VUE_APP_MSAL_KNOWN_AUTHORITY=<yourB2Cname>.b2clogin.com

For complete setup please refer this blog post.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda