Forum Discussion
Storing persistent data associated to Teams user
I am developing a Teams Tab App where the user needs to authenticate using an external API which sends back a token. As the tab is reloaded everytime it is exited and entered again, the user would need to authenticate again. I would like to store this token somewhere. localStorage is an option, but it would be even better if I could store this token in some kind of storage associated to the Teams user using the app, so, for example, it does not need to relogin when switching from Team in web to Team standalone app.
For this, and for other use cases, I would like to know whether it is possible to store data associated to the Teams account that is using the app, so it can be later retrieved (something like a localStorage but associated to the account).
I have already had a look at this thread https://techcommunity.microsoft.com/t5/teams-developer/is-there-a-way-to-store-retrieve-persistent-data-in-teams-tab/m-p/1544749#M1549 but I don't see how getContext (as the answer says) can help me with my task. An explanation on this if it's possible will also help.
Thank you
- Sayali-MSFTMicrosoftPeaverin-Thanks for reporting your issue.
We will investigation this issue and get back to you. - Sayali-MSFTMicrosoft
Peaverin -With SSO in Teams, app users have the advantage of using Teams to access apps. After logging into Teams using Microsoft or Microsoft 365 account, app users can use your app without needing to sign in again. Your app is available to app users on any device with access granted through Azure AD.
Reference Document-Overview to authentication for tabs using SSO in Teams with Azure AD - Teams | Microsoft Learn
Sample Link-Microsoft-Teams-Samples/samples at main · OfficeDev/Microsoft-Teams-Samples (github.com) - Mikel85570Copper ContributorHello,
I have the same problem to store session dependent data e.g. in a cookie. In a MS-Teams APP I get the UserID via a URL parameter. Based on this, it would be possible to store user-dependent data. However, all other calls to the APP unfortunately have no more user-related references, so it is not possible to access stored data. The TeamJS SDK offers the possibility to retrieve the data via getContent() but my question would be how to get this content information into my server side backend code. My webpage is a .CSHTML page with RAZOR. the backend code is provided via the appropriate controller in CS.
Would this way be possible or is there an example where I can see this. I would be grateful for any help.
About SSO I actually did not want to go because I currently do not need resources from MS Azure.
Thanks a lot Mike- ChetanSharma-msftMicrosoftHello Mikel85570, Peaverin - Sorry for delay in response.
Could you please confirm whether your issue has resolved or still looking for any further help here?- Mikel85570Copper ContributorHello ChetanSharma-msft,
I lacked the exact understanding about working with SSO.
helped me hit the following article:
https://techcommunity.microsoft.com/t5/teams-developer/i-need-help-on-best-practice-with-sso-on-a-custom-teams-app-in/m-p/3680821/highlight/true#M6828
Thanks Mike