mvertopoulos / vue-msal

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

Getting 401 request on graph call, something wrong with token #39

Closed Lengo46 closed 2 years ago

Lengo46 commented 3 years ago

If I use the /me, it is working. If I change the URL to https://graph.microsoft.com/v1.0/me/calendars, it giving a 401 error.

let result = await this.$msal.msGraph('https://graph.microsoft.com/v1.0/me/calendars');

I've done the following steps.

  1. accepted all premission and scopes on user level
  2. generated new tokens, with wait this.$msal.acquireToken({ scopes: ["user.read", "Calendars.ReadWrite", "Calendars.ReadWrite.Shared"] }), still no luck
  3. tokens aren't accepted for the calendar call.
  4. used the newly genereated tokens to do direct API request.
  5. using a token from the https://developer.microsoft.com/en-us/graph/graph-explorer is working
  6. token is showing the right scopes.
  7. changed the 'authority', as I'm a guest user on the tenant where the application is created.

Vue.use(msal, { auth: { clientId: 'a8d208xee-dc-x4x03x8xx-XXXX-fxx17d8e8d0119', requireAuthOnInitialize: true, authority: 'https://login.microsoftonline.com/72046464-XXXX-XXX-85exxc-594e7bb34df4/' }, request: { scopes: ["user.read", "Calendars.ReadWrite", "Calendars.ReadWrite.Shared"] } });

Screenshot 2020-10-07 at 12 19 32

{ "error": { "code": "NoPermissionsInAccessToken", "message": "The token contains no permissions, or permissions can not be understood.", "innerError": { "requestId": "df85ed16-f3a7-49ff-83e4-e62bf0b4fe6d", "date": "2020-10-07T10:38:53", "request-id": "df85ed16-XXXX-49ff-XXX-e62bf0b4fe6d", "client-request-id": "df85ed16-f3a7-XXXX-XXXXX-e62bf0b4fe6d" } } }

swc commented 3 years ago

I'm getting the exact same response, though in my case I'm trying to access /me/photo rather than /me/calendars. The "User.Read" permission is present in my scopes, and this is not a personal account so /photo is supported.

@Lengo46 Did you ever find a solution?

christiana-1 commented 3 years ago

I am having the same issue. Did anyone find a solution? @Lengo46 @swc

Lengo46 commented 2 years ago

I got it working with adding a redirectUri and postLogoutRedirectUri, and not using request

Vue.use(msal, {
  auth: {
    clientId: 'XXXX-XXX-XXXX',
    requireAuthOnInitialize: false,
    authority: 'https://login.microsoftonline.com/XXXX-XXXX-XXXX/',
    redirectUri: process.env.VUE_APP_FRONTEND,
    postLogoutRedirectUri: process.env.VUE_APP_FRONTEND,
  },
  system: {
    tokenRenewalOffsetSeconds: 1000,
  },
})