Xamarin.Forms WebAuthenticator and Google

1.7k views Asked by At

I have been trying now for a while to retrieve Google Calendar information from a google user in Xamarin.Forms.

I started my journey using Xamarin.Auth but I could not get past an issue where after a login the CustomTab in my Android App would not close. Seems to have been an ongoing problem for years now and several people proposed hacks to get around this problem. I gave up on Xamarin.Auth at this point

So I tried to use Xamarin.Forms Web Authenticator to retrieve the calendar information. The documentation does not mention how to authenticate with Google so I tried this

var authResult = await WebAuthenticator.AuthenticateAsync(
                new Uri("https://accounts.google.com/o/oauth2/auth"), // auth url
                new Uri("packageNameOfMyApp://");        // redirect url

I am getting an invalid request error

screenshot

How do I have to choose the first parameter of AuthenticateAsync to properly authenticate with Google? Do I have to somehow encode the ClientId from my app I obtained after configuring my application login via the Google Developer Console?

1

There are 1 answers

1
Mouse On Mars On BEST ANSWER

It is not possible to use WebAuthenticator with Google. Google requires a web browser to do the authentication and does not permit your app to authenticate by itself. For the same reason, an approach where you use WebView in your app to navigate to the Google authentication site will fail