1

Brief of what I am trying to achieve: Would like to create root folder properties for a list thats in SharePoint online host web from a remote web service hosted in azure web app.

Have the hybrid set-up as below:

  1. SharePoint Hosted Add-in
  2. Azure Web app - Provider hosted add-in which has wcf service.
  3. Registered my remote add-in using http:///_layouts/15/AppRegNew.aspx form.
  4. Have the client ID & client secret by registering add-in.
  5. updated the add-in manifest xml with the above client id & add-in web config with above client id & client secret.

From the SharePoint hosted add-in page on button click, I am able to call the published remote wcf service end point with parameters (hostWebUrl, listId, propKey, propValue).

Created a client context = new clientcontext(hostWebUrl), how ever I get 403 forbidden error at this point.

All the web sources suggest to get contexttoken, but since this is a wcf service there is no HTTPRequest instead have the requestcontext.

How do I get the contexttoken and authenticate the host web using oAuth?

Any help with this & a working example would be highly appreciated.

Many Thanks, Shan

2
  • Just to add on for the above issue: I have been trying to get a new context token by doing a post request for url - https://<SPHostUrl>/_layouts/15/AppRedirect.aspx?client_id=<app registered client id>&redirect_uri=<encoded wcf service end point url>, the above request is happening in the hosted app js on a button click. However when I debug I get error "The remote server returned the following error while establishing a connection - Forbidden"
    – ShanVeer
    May 19, 2016 at 11:32
  • Apologise, for this post in first place. I am able to resolve the above issue by having correct scope in the appmanifest.xml. I was pointing the scope to hostweb url instead of the string literal like this: <AppPermissionRequest Scope="sharepoint/content/sitecollection/web" Right="FullControl" />
    – ShanVeer
    Jun 7, 2016 at 14:03

1 Answer 1

0

I apologise for this post in first place. I am able to resolve the above issue by having the correct scope in the appmanifest.xml. I was pointing the scope to hostweb url instead of the correct string literal like this:

<AppPermissionRequest Scope="sharepoint/content/sitecollection/web"; Right="FullControl" /> 
2
  • 1
    Hey, can you update your answer properly please, I am also facing same issue.
    – Mihir
    May 5, 2017 at 14:33
  • Hello Mihir, In my case I did a simple human error by wrongly typing the string literal for the add-in scope in AppPermissionRequest element in the AppManifest.xml. Please see the post: dev.office.com/sharepoint/docs/sp-add-ins/… . Hope this helps. Cheers
    – ShanVeer
    May 10, 2017 at 6:43

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .