2

I've created an app in sharepoint and want this app to query the site users list: https://test.sharepoint.com/_api/web/siteusers. I've given the app the following permissions in the app's Permission Request XML using this URL: https://test.sharepoint.com/_layouts/15/AppInv.aspx

    <AppPermissionRequests>
    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />
</AppPermissionRequests>

So basically I trigger a flow when something is added in a sharepoint list and I get the access token by running a post request to https://accounts.accesscontrol.windows.net/common/tokens/OAuth/2 combining the clientid,appid and tenantid from the sharepoint app I created, in the body of the request.

I then use this access code below to query the site user list

When I run a get request in flow or in fiddler:

GET https://test.sharepoint.com/_api/web/siteusers
Accept: application/json;odata=verbose
Content-Type: application/json;odata=nometadata
Host: test.sharepoint.com
Authorization: Bearer <access code>

I get the following:

"Access denied. You do not have permission to perform this action or access this resource." or {"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}

Can anyone point me in the right direction?

Thanks.

1 Answer 1

0

You may use AllowAppOnlyPolicy="true" to elevate privileges.

Check this link for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.