SharePoint Online RER Configuration and Debugging #2 (ClientContext = NULL)


As for this question, I found the mainly reason is ClientID and ClientSecret. I found sometimes I register a new ClientID and ClientSecret cannot work. So I changed some information format. as follows:

When I register the App, Redirect URI: I give it whole URL ( must include Port Number ) like this   https://XXXXX.azurewebsites.net:443/Pages/SettingSecurity.aspx

before solving the issue, My redirect URI is “https://XXXXX.azurewebsites.net” … I don’t know whether or not this is the mainly problem to influence my code. But finally I sorted it out.

Other Problems are:

AppManifest: When I published the “App for SharePoint”, I didn’t change the Url (~remoteAppUrl ) to the Url of the Production with the port number explicit.

  1. Debugging: <StartPage>~remoteAppUrl/Pages/SettingSecurity.aspx?{StandardTokens}</StartPage>
    Production:   <!–<StartPage>https://XXXXX.azurewebsites.net:443/Pages/SettingSecurity.aspx?{StandardTokens}</StartPage>–>
  2. if you wanna debug it, pay close attention to the following line: ClientId=”*” ( don’t need to add any ClientId, keep * ), on the contrary, if you wanna publish it into the Production, you need to change ” * ” to ID like ( ad95a175-b4bb-481e-b644-526b5f37ae02 )

<AppPrincipal>
<RemoteWebApplication ClientId=”*” />
</AppPrincipal>

Elements.XML: It’s the same with the AppManifest

  1. <UrlAction Url=”~remoteAppUrl/Pages/SettingSecurity.aspx?{StandardTokens}&amp;SPListItemId={ItemId}&amp;SPListId={ListId}&amp;SPSource={Source}&amp;SPListURLDir={ListUrlDir}&amp;SPItemURL={ItemUrl}”/>
  2. <!–<UrlAction Url=”https://XXXXX.azurewebsites.net:443/Pages/SettingSecurity.aspx?{StandardTokens}&amp;SPListItemId={ItemId}&amp;SPListId={ListId}&amp;SPSource={Source}&amp;SPListURLDir={ListUrlDir}&amp;SPItemURL={ItemUrl}”/>–>

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.