简体   繁体   中英

How to develop a multi-user Xamarin.Forms app with Azure AD B2C authentication

I am having an unusual hard time finding an example of how to develop a multi-user Xamarin.Forms app. Imagine you wanted to develop an app for UWP, iOS and Android that users can log into and then "do stuff".

It does not matter what - for example taking notes for later access.

Since I am using Microsoft Azure, I would love to have an example which makes use of Azure Active Directory B2C for authentication (including the usage of identity providers such as Microsoft, Facebook, Google, etc.) and Azure Mobile App Service / Azure SQL, etc.

While there are samples available that show how to use ADB2C I didn't find anything related to how you would implement a multi-user app (eg best strategies for the database schema, access management and how this works best with an own Restful API backend and how to include it in your client code, ie Model, Controller,...)

Does anyone of you happen to know an end-to-end sample for this type of Scenario?

Best regards, Christian.

To setup authentication for B2C, I would recommend MSAL. Here are some samples: https://github.com/Azure-Samples/active-directory-b2c-xamarin-native

There are also samples available for the WebApi.

This is a simple Xamarin Forms app showcasing how to use MSAL to authenticate users via Azure Active Directory B2C, and access an ASP.NET Web API with the resulting token.

If you want to know how to setup your database to actually store user data, I would recommend using the claims provided in the token to identify the user. The best way identify the user reliably would be to use the objectId claim. It stays the same even if the user changes their email address.

The claims can also be used to show user information in your app, eg display name or email. You need to add the scope profile to your authentication request to get this data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM