this happened when I tried to use @microsoft/teams-js for Single Sign-on (SSO) purposes in nuxtjs.
<template>
<Tutorial />
</template>
<script>
export default {
name: 'IndexPage',
async mounted () {
const microsoftTeams = await import('@microsoft/teams-js')
// console.log('client => ', microsoftTeams)
microsoftTeams.authentication.getAuthToken({
successCallback: (token) => {
console.log('token', token)
microsoftTeams.appInitialization.notifySuccess()
},
failureCallback: (message) => {
// console.log('error', message)
microsoftTeams.appInitialization.notifyFailure({
reason: microsoftTeams.appInitialization.FailedReason.AuthFailed,
message
})
},
resources: ['']
})
}
}
</script>
CodePudding user response:
Initialize the library, before calling other methods, as per the documentation:
microsoftTeams.initialize()
This of course only works when running in a Teams app (tab or personal)