Jul 16 2020 03:13 AM
Hi,
I am working on a custom app for MS teams. It is not a bot but it is a tab app. I need to authenticate logged in user to MS teams using c#. Please let me know how to authenticate user and show the user profile of logged in user.
Thanks,
Jul 16 2020 03:35 AM
Use REST API service provided by Microsoft inside your application.
you can authenticate the user and and fetch user details using API.
Any services , be it Tabs, Bots etc., everything uses the same authentication process.
You can use the following links to get more idea of how to do it.
https://www.c-sharpcorner.com/article/authentication-with-office-365-in-C-Sharp/
https://github.com/microsoftgraph/aspnet-snippets-sample
cheers.
Jul 16 2020 03:53 AM
Hi @gk_vasudev ,
Thank you so much for your reply.
Is it possible that user is logged in to MS teams already so it can auto login to custom app pages using same credentials?
As per your answer, user has to login by his Office 365 credentials again in the app.
Thanks,
Jul 16 2020 04:22 AM
@Rajesh Lohar You can implement SSO for tab. SSO picks up the credentials of the user from teams login and the user does not have to enter the credentials again. Here is the docs for SSO and the sample. But, currently we do not have a complete sample in C#. But since this is just a web page you can still use it in your C# solution.
Jul 16 2020 04:32 AM
Thank you @Gousia_Begum .
Please let me know if you have complete sample in c#. The information shared by you is really useful.
Thanks
Jul 16 2020 04:39 AM - last edited on Jul 16 2020 09:50 AM by Dylan_Snodgrass
Jul 16 2020 04:39 AM - last edited on Jul 16 2020 09:50 AM by Dylan_Snodgrass
@Rajesh Lohar
if thats the case ,
Then u could a request an authentication token from microsoft teams
and use the token information to authenticate the user to your application.
by this way the user would be automatically logs in to your custom application.
This is "Single Sign-on" Concept based on the "on-behalf-of" flow.
Please go through these links to get a clear idea about the process and how to do it.
its mostly in Js, but i think you would be able to figure out to do it in asp.net and c#
https://docs.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/auth-aad-sso
https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow#service-...
https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols
Jul 16 2020 04:39 AM
@Rajesh Lohar Unfortunately, we do not have a complete sample for SSO in C#. But you can use the code from the NodeJS sample in your app's web page.