Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

530
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!