How to authenticate a user that was redirected to a web application from a desktop application.

Justin Armstrong 0 Reputation points
2024-06-14T20:34:10.4766667+00:00

I am having an issue trying to use Azure AD B2C to use SSO between my desktop application and my web application. The issues is almost exactly what is described in this question: https://video2.skills-academy.com/en-us/answers/questions/1519209/how-to-authenticate-a-user-that-was-redirected-to?page=1&orderby=Helpful&comment=answer-1440349#newest-answer-comment

I have tried following the steps in that answer but I am having issues trying to implement steps 5 and 6. My hope is that someone might be able to point me to a code sample of where I can pass in the access token to my Web Application and use the access token to authenticate the user without having them sign in again.

I have the User Flows session behavior set to use the tenant option for SSO. Currently I have both applications set to use the same user flow. They do use different App Registrations though since the setup for a Desktop applications is different from the App Registration settings for my Web Application.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,344 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,141 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,354 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 60,361 Reputation points
    2024-06-14T21:20:08.72+00:00

    you really should have an api encrypt call on the website the mobile app can call to encrypt the access token before passing on the url (unless its a webview in the desktop app).

    it really pretty simple. the mobile app navigate the browser (or webview) to the website login via access token endpoint you create:

    https://mysite.com/login?token=<the token>

    in the code for the endpoint, you validate the access token. then create custom credentials based on the user and claims in the access token.