sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Invalid redirect in AppForSharePointOnlineWebToolkit

Open phawrylak opened this issue 9 years ago • 2 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

When user starts SharePoint Provider-hosted add-in for the first time, he is redirected to AppRedirect.aspx to acquire context token (access and refresh tokens) and then redirected back to the application (context token is saved in session). As long as session and access token don't expire, user can use application to connect to SharePoint using user access token. When access token expires (it's valid for 1 hour), application should get new access token using refresh token saved in session.

Observed Behavior

When access token expires, user is redirected to AppRedirect.aspx.

Steps to Reproduce

  1. Create new SharePoint Provider-hosted add-in.
  2. Install [email protected] from NuGet.
  3. Increase session timeout in Web.config to 2 hours:
<system.web>
    <sessionState mode="InProc" timeout="120" />
</system.web>
  1. Add [SharePointContextFilter] attribute to controller action.
  2. Deploy SharePoint Add-in and start application.
  3. Refresh page after more than 1 hour and you will be redirected to AppRedirect.aspx.

Fix

https://github.com/phawrylak/AppForSharePointOnlineWebToolkit/commit/5431fd4a9cb3a56a8c7243eb0029fd4ac6f464c2

By the way, I have changed SharePointContextFilterAttribute implementation to authentication filter instead of action filter (this causes execution on earlier request stage and allows to write authorization filter that connects to SharePoint). This change is in the following commit:

https://github.com/phawrylak/AppForSharePointOnlineWebToolkit/commit/5337cef897e39147ec5c531a5ff31bda112033e6

Version

[email protected]

phawrylak avatar Oct 01 '17 02:10 phawrylak

We closed this issue as it had not activity within last 180 days. This is a generic process we have decided to perform for issues, which have not been explicitly marked still to be "work in progress" based on tags. We are performing this cleaning to make sure that old issues that have already been solved (but not closed) or are no longer relevant are cleaned out and make the issues more manageable. If this issue still valid, we would ask you to open a new issue and follow the guidance in the issue template related on the recommended location. We do apologize any inconveniences this might cause. Please do remember that issues in the issue lists are also messages for others in the community, so you can also check if you can assist on any of them. “Sharing is caring!”

spdevdocs avatar Apr 29 '18 12:04 spdevdocs

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 29 '20 00:01 msft-github-bot