Confiuration code:
function fetchAzureMSALInstance() {
let azureMsalConfig = {
auth: {
clientId: 'e154806f-ba69-417f-a60c-b1c89b2ffa01',
authority: 'https://login.microsoftonline.com/common',
redirectUri: `${window.location.origin}`
},
cache: {
cacheLocation: 'sessionStorage',
storeAuthStateInCookie: false
}
}
return new msal.PublicClientApplication(azureMsalConfig)
}
I have a button in the Teams.vue file, and when I click on it:
reviewPermissions() {
`const accessTokenRequest = { scopes: ["https://graph.microsoft.com/.default"], account: self.msalAccount }
self.azureMsalInstance
.acquireTokenSilent(accessTokenRequest)
.then(response => {
console.log('Login successful', response)
})
.catch(error => {
//Acquire token silent failure, and send an interactive request
if (error instanceof AuthError) {
//use loginPopup for token, loginRedirect for code
self.azureMsalInstance
.loginRedirect(
{
scopes: ["https://graph.microsoft.com/.default"],
prompt: 'consent',
response_type: 'code',
response_mode: 'query'
}
)
.then(function (accessTokenResponse) {
// Acquire token interactive success
let accessToken = accessTokenResponse
self.userAccount = accessTokenResponse.account
})
.catch(function (error) {
// Acquire token interactive failure
console.log(error)
})
}
})
},`
}
My issue is that my product has fragmented URLs, and I cant go and change it simply. I have to work by it. I need to redirect my successful authentication to https:localhost:8080/#/teams (temporary URL) and it would add https:localhost:8080/#/teams?code={CODE} like this ideally. But currently, it adds
https://localhost:8080/#/code=0.AW4A5AR-DlurFE65uFJDKf4ddG-AVOFpun9BpgyxyJsv-gFuAIU.AgABBAIAAAApTwJmzXqdR4BN2miheQMYAgDs_wUA9P_joXDqKpXZKp9lIwysG7256qw7dZV1d_oKavvy6M2VRONZrnpUh`
, now my application does not have a route with
https://localhost:8080/#/code
Even lets assume that I give redirectUri like https:dev/teams, it will still attach code like https:dev/teams/#code….
Summarizing problems: 1. I want to use fragmented URLs. 2. code is not coming in as ?code query params My backend wants code, and not token, so I need to go with loginRedirect Approach