Abraham Luna
Abraham Luna

Reputation: 110

Is this really the process for authenticating users with the Google platform using Xamarin?

I am following the tutorial located here: https://developer.xamarin.com/guides/xamarin-forms/cloud-services/authentication/oauth/

I got to the step titled: Presenting the Sign-In User Interface. It says that, "When the Login method is invoked, the sign-in user interface is presented to the user in a tab from the device's web browser."

Now is this really the process when using Xamarin? Because the other apps I've downloaded and played with don't open the browser and then open a new tab to give me a choice of which account to choose. Those apps pop up a small page on top of the app and allows me to select an account. If this Xamarin process is different I am not going to use it when developing my app. Please clear this up for me thanks.

Upvotes: 0

Views: 217

Answers (1)

Krumelur
Krumelur

Reputation: 33048

There is no such thing as as "Xamarin's way of oAuth".

oAuth is about authenticating users through 3rd parties like Google, Facebook, Twitter etc. There are different oAuth flows which are mostly used: the implicit grant and the authorisation code grant. For mobile apps the implicit flow is common because auth code flow involves the app keeping a secret which a mobile cannot really guarantee. For a great overview of these flows I can recommend this lecture from Xamarin.University.

These flows are the same no matter which underlying development stack you are using.

The documentation you are referring to is using a library to help using these flows: Xamarin.Auth. As a matter of fact you don't have to use this library at all. This library helps with storing tokens, sending requests that include the required tokens, detect endpoint redirects etc. Part of using this library is presenting the UI where the 3rd party vendors login form is shown.

This is what you do when calling:

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);

The actual implementation of presenting the UI is platform specific. On iOS the UI os shown modally if that's how you are coding it. If you change this code to show the UI as a small popup floating on top of existing content, you can of course do this. This is true for any given platform.

Upvotes: 1

Related Questions