Skip to content

Commit 0d88844

Browse files
authored
Final edit of Develop sp-add-ins topics (SharePoint#1193)
* Final edit * Final edit * Final edit * trying to fix chart * Trying to fix chart * Final edit
1 parent 215ba2e commit 0d88844

6 files changed

+447
-934
lines changed

docs/sp-add-ins/access-sharepoint-data-from-add-ins-using-the-cross-___domain-library.md

Lines changed: 120 additions & 250 deletions
Large diffs are not rendered by default.

docs/sp-add-ins/create-and-use-access-tokens-in-provider-hosted-high-trust-sharepoint-add-ins.md

Lines changed: 90 additions & 157 deletions
Large diffs are not rendered by default.

docs/sp-add-ins/create-high-trust-sharepoint-add-ins.md

Lines changed: 174 additions & 346 deletions
Large diffs are not rendered by default.

docs/sp-add-ins/handle-security-tokens-in-provider-hosted-low-trust-sharepoint-add-ins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ The following is a decoded example of a user+add-in access token generated by AC
106106

107107
Note that all the values must be lowercase. (User+add-in access tokens are the same in the [Context Token flow](context-token-oauth-flow-for-sharepoint-add-ins.md) and the [Authorization Code flow](authorization-code-oauth-flow-for-sharepoint-add-ins.md).)
108108

109-
```js
109+
```json
110110
{
111111
"aud": "00000003-0000-0ff1-ce00-000000000000/company.sharepoint.com@040f2415-e6e3-4480-96ce-26ef73275f73",
112112
"iss": "00000001-0000-0000-c000-000000000000@040f2415-e6e3-4480-96ce-26ef73275f73",
@@ -138,7 +138,7 @@ Note that all the values must be lowercase. (User+add-in access tokens are the s
138138

139139
The following is a decoded example of an add-in-only access token generated by ACS to be used for calls to SharePoint using the [add-in-only policy](add-in-authorization-policy-types-in-sharepoint.md). White space has been added for readability. The token complies with the [JSON Web Token](https://datatracker.ietf.org/doc/rfc7519/) protocol. See Table 2 for details about the properties in the claim set. (The add-in-only policy is not available for applications that use the [Authorization Code flow](authorization-code-oauth-flow-for-sharepoint-add-ins.md), because they do not have an add-in manifest file and, thus, cannot request permission to use add-in-only calls.)
140140

141-
```js
141+
```json
142142
{
143143
"aud":"00000003-0000-0ff1-ce00-000000000000/company.sharepoint.com@040f2415-e6e3-4480-96ce-26ef73275f73",
144144
"iss":"00000001-0000-0000-c000-000000000000@040f2415-e6e3-4480-96ce-26ef73275f73",
@@ -283,7 +283,7 @@ Response.Redirect(TokenHelper.GetAppContextTokenRequestUrl(sharePointUrl, Server
283283

284284
The following is an example of a context token. The small JavaScript Object Notation (JSON) object at the top contains metadata about the token. These properties are the same as in access tokens (see earlier). The value of the **alg** property is the name of the algorithm that is used to generate the signature that ACS appends to the token. See Table 3 for details about the properties in the payload of the token. Note that all the values must be lowercase. (White space has been added for readability.)
285285

286-
```js
286+
```json
287287
{"typ":"JWT","alg":"HS256"}
288288
.
289289
{

docs/sp-add-ins/troubleshooting-high-trust-sharepoint-add-ins.md

Lines changed: 25 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
---
22
title: Troubleshooting high-trust SharePoint Add-ins
3-
ms.date: 09/25/2017
3+
description: Use the Fiddler tool and other guidance for resolving high-trust issues.
4+
ms.date: 12/29/2017
45
ms.prod: sharepoint
56
---
67

78

89
# Troubleshooting high-trust SharePoint Add-ins
9-
Get some help with problems developing high-trust SharePoint Add-ins.
10-
11-
12-
13-
14-
This article describes the Fiddler tool and also provides some guidance for resolving some specific issues.
15-
1610

1711
## Use the Fiddler tool
1812

19-
The free [Fiddler tool](http://www.telerik.com/fiddler) can be used to capture the HTTP Requests sent by the remote component of your add-in to SharePoint. There is a [free extension to the tool](https://github.com/andrewconnell/SPOAuthFiddlerExt) that automatically decodes the access tokens in the requests.
20-
13+
The free [Fiddler tool](http://www.telerik.com/fiddler) can be used to capture the HTTP Requests sent by the remote component of your add-in to SharePoint.
14+
15+
There is a [free extension to the tool](https://github.com/andrewconnell/SPOAuthFiddlerExt) that automatically decodes the access tokens in the requests.
2116

22-
2317
After you have installed Fiddler on the web application server, add the following markup to your web.config file to make requests from your remote web app go through this proxy. This way, you can capture a Fiddler trace and see the full response from SharePoint when you get an error.
2418

2519
> [!NOTE]
2620
> Ensure that you remove this markup if you are not running Fiddler. If you don't remove the markup, your add-in won't be able to make HTTP requests.
27-
28-
29-
30-
3121
3222
```XML
3323
<system.net>
@@ -38,18 +28,14 @@ After you have installed Fiddler on the web application server, add the followin
3828

3929
```
4030

41-
After you have Fiddler installed, you can also check the response headers from SharePoint, which will include a request GUID. This request GUID is a correlation ID you can look up in the logs to find any log errors associated with that request.
31+
After you have Fiddler installed, you can also check the response headers from SharePoint, which include a request GUID. This request GUID is a correlation ID that you can look up in the logs to find any log errors associated with that request.
4232

4333

44-
34+
<a name="UnauthorizedException"> </a>
4535

4636
## 401 Unauthorized error
47-
<a name="UnauthorizedException"> </a>
48-
49-
Several things can cause a **401 Unauthorized** error when the high-trust add-in first accesses SharePoint. If you are using the Client-side Object Model (CSOM), the error looks something like the following:
50-
5137

52-
38+
Several things can cause a **401 Unauthorized** error when the high-trust add-in first accesses SharePoint. If you are using the Client-side Object Model (CSOM), the error looks something like the following:
5339

5440
```C#
5541
[WebException: The remote server returned an error: (401) Unauthorized.]
@@ -65,11 +51,6 @@ Several things can cause a **401 Unauthorized** error when the high-trust add-i
6551
```
6652

6753
If you are using the TokenHelper file and Windows identity, the code that triggers the exception looks like the following:
68-
69-
70-
71-
72-
7354

7455
```C#
7556
ClientContext clientContext =
@@ -78,67 +59,47 @@ clientContext.Load(clientContext.Web);
7859
clientContext.ExecuteQuery();
7960
```
8061

81-
Your first step in troubleshooting the issue is to use the Visual Studio debugger to verify that the access token and the **ClientContext** object are constructed successfully. If they are, investigate the following possibilities:
82-
83-
84-
85-
**Possible issues and resolution:**
86-
87-
62+
Your first step in troubleshooting the issue is to use the Visual Studio debugger to verify that the access token and the **ClientContext** object are constructed successfully. If they are, investigate the following possibilities:
8863

64+
**Possible issue and resolution**:
8965

9066
- There is no user profile created for the user who is accessing the remote web application. Create the user profile.
9167

92-
93-
- Your add-in does not have permission to the resource you are trying to access. Open the SharePoint Management Shell and run that the following Windows PowerShell cmdlet. The variable `$web` is the SharePoint website you are trying to get access to and `$appPrincipal`) is the add-in ID. For more information, see [Set-SPAppPrincipalPermission](http://technet.microsoft.com/en-us/library/jj219714%28v=office.15%29.aspx).
94-
95-
```
96-
Set-SPAppPrincipalPermission -Site $web -AppPrincipal $appPrincipal -Scope Site -Right FullControl
97-
```
68+
- Your add-in does not have permission to the resource you are trying to access. Open the SharePoint Management Shell and run the following Windows PowerShell cmdlet. The variable `$web` is the SharePoint website you are trying to get access to, and `$appPrincipal` is the add-in ID. For more information, see [Set-SPAppPrincipalPermission](https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/Set-SPAppPrincipalPermission?view=sharepoint-ps).
69+
70+
```powershell
71+
Set-SPAppPrincipalPermission -Site $web -AppPrincipal $appPrincipal -Scope Site -Right FullControl
72+
```
9873

99-
- Your web application is accepting anonymous requests. This means there is not a real user identity in the access token. Ensure that anonymous access has been disabled in IIS for the root directory of your remote web application. You can also check this by debugging your remote web application, and checking the value of **Request.LogonUserIdentity** in the default.aspx.cs (or .vb) file to ensure that it's not an anonymous user.
100-
74+
- Your web application is accepting anonymous requests. This means there is not a real user identity in the access token. Ensure that anonymous access has been disabled in IIS for the root directory of your remote web application. You can also check this by debugging your remote web application, and checking the value of **Request.LogonUserIdentity** in the default.aspx.cs (or .vb) file to ensure that it's not an anonymous user.
10175

10276
- Your digital certificate was not added to the trusted certificate store. Be sure you have followed the procedures in [Package and publish high-trust SharePoint Add-ins](package-and-publish-high-trust-sharepoint-add-ins.md).
10377

104-
78+
<a name="DomainRelatedErrors"> </a>
10579

10680
## Miscellaneous SSL and ___domain-related authorization errors
107-
<a name="DomainRelatedErrors"> </a>
10881

10982
A mismatch of ___domain names in configuration files and registration forms can prevent authorization. The following four values have to be exactly the same:
110-
11183

84+
- The **Add-in Domain** that is specified when the SharePoint Add-in is registered on AppRegNew.aspx.
11285

113-
114-
- The **Add-in Domain** that is specified when the SharePoint Add-in is registered on AppRegNew.aspx.
115-
116-
117-
- The ___domain under which the remote web application's security certificate is registered.
118-
86+
- The ___domain under which the remote web application's security certificate is registered.
11987

120-
- The ___domain part of the **StartPage** value in the AppManifest.xml file.
121-
88+
- The ___domain part of the **StartPage** value in the AppManifest.xml file.
12289

123-
- The ___domain part of the URLs of any event receivers specified in the AppManifest.xml.
124-
90+
- The ___domain part of the URLs of any event receivers specified in the AppManifest.xml.
12591

12692
In connection with this point, note the following:
127-
12893

129-
94+
- If the remote component of your SharePoint Add-in is using any port other than 443, you must explicitly include the port as part of the ___domain in all four places; for example, `MarketingServer:3333`. (You must use the HTTPS protocol, for which the default port is 443.)
13095

131-
- If the remote component of your SharePoint Add-in is using any port other than 443, you must explicitly include the port as part of the ___domain in all four places; for example, `MarketingServer:3333`. (You must use the HTTPS protocol for which the default port is 443.)
96+
- The ___domain needs to be hardcoded in the **StartPage** value (and any event receiver URLs) of the AppManifest.xml file before the add-in is packaged. If you use the Publish Wizard in Visual Studio to package the add-in, you are prompted for the ___domain, and the Office Developer Tools for Visual Studio inserts it into the **StartPage** value for you (in place of the `~remoteWebUrl` token that is used during debugging. But if you are not using the Publish Wizard, you must manually replace the token with the ___domain (and protocol); for example `https://MarketingServer` or `https://MarketingServer:3333`.
13297

133-
134-
- The ___domain needs to be hardcoded in the **StartPage** value (and any event receiver URLs) of the AppManifest.xml file before the add-in is packaged. If you use the **Publish** wizard in Visual Studio to package the add-in, you will be prompted for the ___domain and the Office Developer Tools for Visual Studio will insert it into the **StartPage** value for you (in place of the `~remoteWebUrl` token that is used during debugging. But if you are not using the **Publish** wizard you must manually replace the token with the ___domain (and protocol); for example `https://MarketingServer` or `https://MarketingServer:3333`.
135-
136-
98+
<a name="DomainRelatedErrors"> </a>
13799

138100
## Runtime error saying that there's no certificate with that serial number
139-
<a name="DomainRelatedErrors"> </a>
140101

141-
If you are sure you have the correct certificate serial number in the web.config and you can see the certificate in the **Windows Certificate Store**, then there may be a hidden extra character in the serial number in the web.config. This will happen if the serial number is copy'n'pasted from the **Microsoft Management Console**. Delete the entire serial number value from the web.config and *manually* retype it.
102+
If you are sure you have the correct certificate serial number in the web.config, and you can see the certificate in the Windows Certificate Store, there may be a hidden extra character in the serial number in the web.config. This happens if the serial number is copied and pasted from the Microsoft Management Console. Delete the entire serial number value from the web.config and *manually* retype it.
142103

143104
## See also
144105

0 commit comments

Comments
 (0)