How to use Xamarin OAuth Presenters Login method for Google

VijayKumar.0628VijayKumar.0628 USMember ✭✭
edited July 2017 in Xamarin.Forms

Hi All,

I am using the Xamarin OAuth2 Presenters method to enable google plus login in my xamarin application, since the webviews are now disavowed by Google to authenticate the user information through the mobile devices. I have followed the method as per the sample in this link.
https://developer.xamarin.com/guides/xamarin-forms/cloud-services/authentication/oauth/#Setup

And I am getting the null exception method at the calling of the Login method from the presenter to show the login page to the user to authenticate their credentials. Getting the error in the below bold line of the code.

var authenticator
= new Xamarin.Auth.OAuth2Authenticator
(
clientId: GoogleServices.ClientId,
clientSecret: null,
scope: "https://www.googleapis.com/auth/userinfo.profile",
authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"),
redirectUrl: new Uri(GoogleServices.RedirectUri),
accessTokenUrl: new Uri("https://www.googleapis.com/oauth2/v4/token"),
getUsernameAsync: null,
isUsingNativeUI : true
);

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

Find the attached image of the exception i am getting.

Let me know how to clear this exception. I have also found a sample from the GitHub link for the OAuth authentication, https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences but it is not compiling in Visual Studio throwing numerous errors.

Thanks,
Vijayakumar Y.

Best Answer

  • VijayKumar.0628VijayKumar.0628 US ✭✭
    Accepted Answer

    Hi Everyone,
    I have resolved this issue by updating my Android SDK to API 24 and updating the assemblies in my project to v25.3.1

Answers

  • VijayKumar.0628VijayKumar.0628 USMember ✭✭

    Hi Guys,

    After resolving the above error, ended up with a another error while debugging the application. Attached the image of the exception below. This happens after using the login method from the Presenters. In the below line.

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

    Any ideas on how to resolve the above exception would be really great.

    Thanks,
    Vijayakumar Y.

  • VijayKumar.0628VijayKumar.0628 USMember ✭✭

    Anyone had a chance to check this issue, i found some answers regarding the update of the Android.Support.v4 solves this issue. But that produces new no resource found issues. Can anyone let me know how to resolve this.

  • VijayKumar.0628VijayKumar.0628 USMember ✭✭

    Hi Everyone,
    I have resolved this issue by updating my Android SDK to API 24 and updating the assemblies in my project to v25.x.x

  • VijayKumar.0628VijayKumar.0628 USMember ✭✭
    Accepted Answer

    Hi Everyone,
    I have resolved this issue by updating my Android SDK to API 24 and updating the assemblies in my project to v25.3.1

Sign In or Register to comment.