mvertopoulos / vue-msal

Vue plugin for using Microsoft Authentication Library (MSAL)
MIT License
123 stars 66 forks source link

Receiving error after changing app to https #53

Open JaeTLDR opened 2 years ago

JaeTLDR commented 2 years ago

I have been using this library successfully with a website running locally on http, I have now updated my redirecturi (et al) to use https, as well as vue cli to https, and I get the following error:

{
    "error": {
        "code": "InvalidAuthenticationToken",
        "message": "CompactToken parsing failed with error code: 80049217",
        "innerError": {
            "date": "2022-05-25T01:13:55",
            "request-id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "client-request-id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        }
    }
}

This was working without issue before switching to https. (redirecturl in AAD being http://localhost:8080/signedin => https://localhost:8080/signedin), and occurs on new browsers, clearing localstorage and cookies, and incognito.

my msal config:

import msal from "vue-msal"
Vue.use(msal, {
  auth: {
    clientId: C.AADappDetails.clientId,
    authority: `https://login.microsoftonline.com/${C.AADappDetails.tenant}/`,
    redirectUri: C.AADappDetails.redirectUri,
    postLogoutRedirectUri: C.AADappDetails.logoutRedirectUri,
    requireAuthOnInitialize: true,
    beforeSignOut:()=>{
      store.commit("auth/resetState")
      console.log("signout")
    },
    onToken:()=>{
        //todo, update vuex
         console.log("ontoken")
    }
  },
  request:{
    scopes: C.AADappDetails.scopes
  },
  framework:{
    globalMixin: true
  },
  graph: {
    callAfterInit: true,
    endpoints: {
      groups: '/me/transitiveMemberOf/microsoft.graph.group?$count=true&$select=id',
      profile: '/me',
      photo: { url: '/me/photo/$value', responseType: 'blob', force: true }
    }
  }
});

and my vue.config.js

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    https: true,
    host: 'localhost',
    port: 8080,
    http2: true, 
    liveReload: true, 
  }
})

Thanks , J

JaeTLDR commented 2 years ago

It appears the azure authentication is working but MSAL using the returned tokens are giving me 401's