Teams: Personal Tab => successful authentication redirects back to login page (Due to cookie not being set)

So we have this web application running, but we wanted to make a Teams app (personal tab) from it. We used App Studio to create the app (manifest and all), but when running it from the sidebar we won’t get past the login screen. On successful login, you get redirected back to the login page (everything happens on the same domain).

But when we tried to run the "app" as a tab within a group, this worked. So we need to find out why this doesn’t work when we run it as a Teams "app".

Any ideas would be appreciated 🙂

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

The problem was that since it’s running inside an iframe (in practice), the cookie set by ASP.NET State needs to state SameSite="None" and Secure="true".

Applications that use <iframe> may experience issues with sameSite=Lax or sameSite=Strict cookies because <iframe> is treated as cross-site scenarios. – https://docs.microsoft.com/en-us/aspnet/samesite/system-web-samesite

So I had to upgrade the .NET Target Framework to 4.7.2, and make the changes stated in this document: https://docs.microsoft.com/en-us/aspnet/samesite/system-web-samesite

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply