denno
denno

Reputation: 139

Xamarin.forms cannot convert from object to system.type with Xamarin.Auth and specific android platform

I'm implementing authentication in a Xamarin.Forms app. I was looking at this sample " TodoAWSAuth - Configuring Google as an OAuth identity provider". In my implementation of OAuthLoginPresenter specific for android I have this code: using Xamarin.Auth;

 namespace InstagramApp.Droid
 {
   public class OAuthLoginPresenter
   {
      public void Login(Authenticator authenticator)
      {
        Xamarin.Forms.Forms.Context.StartActivity(authenticator.GetUI(Xamarin.Forms.Forms.Context));
      }
   }
 }

My:

Xamarin.Forms.Forms.Context.StartActivity(authenticator.GetUI(Xamarin.Forms.Forms.Context));

returns me:

Argument 1: cannot convert from 'object' to 'System.Type'

It is the same of the sample in the link. What could be the problem?

Also in the Xamarin Documentation the code is the same: Xamarin.Auth documentation

Thanks to all

Upvotes: 3

Views: 642

Answers (2)

hvaughan3
hvaughan3

Reputation: 11105

*Edit: The API below has probably changed with Xamarin.Auth 1.5. See moljac's answer.

For me, I am using the activity to start the login page and to pass in the context, but I am also running the code below from within a ContentPage renderer's OnElementChanged() method:

Android.App.Activity activity = Context as Android.App.Activity;

//Initialize authenticator

activity.StartActivity(auth.GetUI(activity));

Upvotes: 1

moljac
moljac

Reputation: 1020

Xamarin.Auth 1.4.x supports Custom Tabs and SafariViewController, but no Xamarin.Forms support what most of the users want. Xamarin.Forms support is in the 1.5.0-alpha soon to be released.

Samples extracted from the repo:

https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences

ComicBook is Xamarin.Forms

Providers Traditional/Standard

Those will give you idea how to do it.

Upvotes: 1

Related Questions