msGraphClientFactory limited use token generated in SPFx Field Customizer
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
-
Create a list with one or more items.
-
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.
-
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.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
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.
;-( Yes, indeed: Permissioning changed from HttpGraphClient to MSGraphClient. My bad. Sorry.
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