For others, I had this same question and a partial answer is here: https://www.reddit.com/r/webdev/comments/vekb7m/ms_graph_api_search_api_little_problem_with_region/
Problem with Search API (part of Graph API) when making requests with my application (it asks for Region)
Hello, here am I with one of those problems that only happen (almost) with Microsoft stuff, ahh I love this :)
So i am using Graph API, more specificly Search API.
I'm using it to get information about all list items in a specific share point site.
I am able to make the request in the graph API website as you can see here:
But then in my node.js app, that is using "Microsoft Graph JavaScript Client Library" npm package library it throws out this error when i make the same request:
" Region is required when request with application permission."
I have tried other Graph api calls (GET instead of POST) and it works with no problems at all.
I have tried to insert a Region attribute in my request body and it demands it to be a GUID, i tried a random GUID and ofc it failed with:
" No ready-to-use APC or ASC stamps were found for request"
If you have any idea what is the guid that i need to put please say something, thanks!
Microsoft Security Microsoft Graph
3 answers
Sort by: Most helpful
-
-
Jitendra Kumar Singh 1 Reputation point
2022-10-28T05:40:27.627+00:00 Is your problem get solved I am also facing the same problem
-
Rogerio Alves 6 Reputation points
2022-10-28T09:37:36.417+00:00 Yes, it got fixed by the project architect, the problem was that i was using an app key to connect to graph api but this search api functionality requires that you pass a user key. The difference is that this user key brings the user permissions/ scopes etc that with an app key you can't get, i think the technical name for the user key is a delegated key.
The way he fixed it is that in the back-end we receive the user key from the front -end, the front end, aka, user/client side got the key from the authentication/login the user did and get stored into cookies. on request sent to back-end we intercept the request and add an header or something into it.This is something that we were already doing, I just didn't had enough knowledge over this and the project at the time to get the correct key from the right place.
In the back-end we have a middleware that validates the user key, get the roles/scopes from it and inject into the request the userid email and permissions obtained from the validation of the key (it validates using a jsonwebtoken NPM package connected to MS login service) to be used by back-end services later.If you are authenticating using microsoft in your website, check network tab and you should have a file called "me" there, i think the key you want is the first one there "access_token". you can decode that token and check if you have the right scopes to use the search api functionality that you want, for what i want i need sites.read.all, to enable me to search in sharepoint stuff so that i the token that has that permission and the one that i use. I have other token in that file called "id_token" that is also a user/delegated key but dosen't contain that role.
Sorry for not being clear, but this is as far as i can go to explain it to you.
This "sites.read.all" scope is defined in azure app service or something, it may require the IT admin of your org to approve the use of that scope and i think is a delegated permission.