1

I am trying to get OAuth code to access sites and lists from SharePoint Online. Below are the steps that I have performed:

  1. Register application at URL https://adventurer.sharepoint.com/_layouts/15/appregnew.aspx
  2. Generate Client ID and Secret at above URL and create the application.
  3. Request OAuth code from user's credentials by accessing below URL:

https://adventurer.sharepoint.com/_layouts/15/OAuthAuthorize.aspx?client_id=ebd57c66-97dd-498d-83f5-eedd6536bbc2&scope=Web.Read List.Write &response_type=code&redirect_uri=https://localhost/SharePointOnlineSample

After authentication from SharePoint server, I get error as "access_denied". I don't know what is causing this issue. If I remove the scope from above URL and grant permission to application using below URL:

https://adventurer.sharepoint.com/_layouts/15/appinv.aspx

and below XML:

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

It works just fine. But I want to know the correct approach. Why is this XML required to grant permission? Why can't I just get OAuth code using scope in request URL?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.