Thursday, March 7, 2013

SharePoint 2013 Provider Hosted App - 401 Unauthorized Error

I've been working on some SharePoint 2013 apps and was building a Provider Hosted app this evening. I followed the step by step instructions in this Microsoft Article and all was going well. Then I tried testing my app and got a 401 unauthorized error.

I searched around and found a few reasons for this error:
- User Profile - it seems you need to have a User Profile created for the user using the app, this wasn't it as I had a user profile.
- Permissions - Your app may be trying to access things it hasn't been granted permission to. This wasn't it either as my app wasn't doing anything, just showing a page.
- Anonymous Access - Your app needs to be able to verify your identity so that it can authorize you in SharePoint. This wasn't my problem either as I was just using F5 to run it, so VS was dynamically creating a web app.
- Certificate Issue - You need to add your app certificate to the trusted certificate store. I had done this through PowerShell earlier but decided to check it out.

Ends up I overlooked the text in the Microsoft Article that states the issuer id needs to be all lowercase letters. Visual Studio's Guid generator alwasy provides all caps and I just copy/pasted.

I removed it and readded and all worked perfectly!

No comments:

Post a Comment