Authenticate a user from a MAUI app against the local Microsoft Identity in the ASP.NET website

Enrico Rossini 236 Reputation points
2023-12-26T20:58:44.3466667+00:00

I have created a website with ASP.NET Core and NET8. In this web application, I added Microsoft Identity and I added Microsoft and Google as external providers. So, a user can register or login with the local credentials or one of the external providers.

On the website, the authentication is working. Now, I want to extend the registration and the login from the MAUI application.

My idea is to create a few APIs for the authentication and in particular:

  • a login endpoint that receives username and password
  • a registration endpoint with all the basic details of the user (name, surname, email and password)

Is this a correct approach or best practice?

The other issue I'm thinking about is the authentication with the external providers. How can I manage the authentication from the app for Microsoft and Google and verify that the user exists in the web application?

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,151 Reputation points Microsoft External Staff
    2023-12-27T03:00:37.1733333+00:00

    Hello,

    Is this a correct approach or best practice?

    For web application authentication, MAUI does not have special circumstances. you can refer to the following document for the guidance on authentication.

    Since certification best practices are a huge part of the content, it is recommended that you refer to the following documents for the guidance on certification.

    The other issue I'm thinking about is the authentication with the external providers. How can I manage the authentication from the app for Microsoft and Google and verify that the user exists in the web application?

    You can link an external account to an account in the program via the Oauth protocol.

    Please refer to Microsoft identity platform and OAuth 2.0 authorization code flow for more details.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.