sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

msGraphClientFactory limited use token generated in SPFx Field Customizer

Open paulewert opened this issue 7 years ago • 4 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

Expecting MSGraphClient to retrieve same results as Graph Explorer for a call to https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items.

Observed Behavior

When using token generated by Graph Explorer, the request for list items returns successfully with the array of item data. However, when using the token generated by MSGraphClient, an empty array is always returned. Removing "/items" from the end of the URL produces identical results for both tokens.

Steps to Reproduce

  1. Create a list with one or more items.

  2. Go to Graph Explorer, sign in to your tenant, and execute the call to get list items from the list you created in step 1 (the request URL will be formed like the one given in "Expected or Desired Behavior" above). The response includes the list items. Copy the authorization token and make the same call in an http tool like Postman. Execute the request. An array of item objects comes back in the response.

  3. Now, put together a SPFx Field Customizer making a call to the MSGraphClient with the same URL (the api function gets passed everything after "v1.0/" from the URL above). Inspect the network request when executed and extract the authorization token used. Put that token in place of the token from Graph Explorer in your http tool (Postman, in my case). Thus, the only change has been the authorization token. Execute the request. This time, the array of item objects is empty. The only thing we have changed is the token.

paulewert avatar Aug 07 '19 23:08 paulewert

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Aug 07 '19 23:08 msft-github-bot

Possibility my SPFx Field Customizer is missing a permission. Verifying that now. This may be a change from HttpGraphClient to MSGraphClient I was not aware of.

paulewert avatar Aug 08 '19 17:08 paulewert

;-( Yes, indeed: Permissioning changed from HttpGraphClient to MSGraphClient. My bad. Sorry.

paulewert avatar Aug 08 '19 17:08 paulewert

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 23 '20 18:01 msft-github-bot