Authentication is an important part of today’s mobile applications, but securely implementing authentication in a mobile app can be a daunting task. In this article, you will learn how to create a basic cross-platform application with Xamarin.Forms and use the WebAuthenticator
class from Xamarin.Essentials together with Okta to quickly and easily add user login to your mobile app.
To continue you will need:
Xamarin is a framework from Microsoft for building cross-platform mobile apps from one shared source code, written in C#, and compiled to each platform’s runtime. Xamarin.Forms is an abstraction on that, enabling developers to share the UI code as well. Xamarin.Essentials is a NuGet package providing cross-platform APIs for accessing and using native platform capabilities. In this article I will show you how to build a simple Xamarin.Forms app and add authentication to it.
Xamarin.Forms is now included in Visual Studio! Create a new project by clicking File>New Project in Visual Studio, select Mobile App (Xamarin.Forms), and click Next. Name the app OktaAuth and click Create. On the next window, select Blank and click OK.
Visual Studio will automatically create a solution with three projects: OktaAuth.Android
for Android, OktaAuth.iOS
for iOS, and OktaAuth
for shared code and user interface. The projects already include Xamarin.Essentials out of the box - however, the included version doesn’t have the WebAuthenticator
class, so you will need to update it to the latest available version which, as of the publish date of this post, is 1.5.3.2
Now, run the app on your attached mobile device (or in the simulator) and you should see a screen like this:
Next, it’s time to secure your users login!
#xamarin #security #developer