locked
facebook login using xamarin auth in xamarin android RRS feed

  • Question

  • User296687 posted

    I am getting below error while facebook login using xamarin auth:

    Below is the code i am using for facebook login and it is working on iOS

        var auth = new OAuth2Authenticator(
                clientId: "1101982928XXXXX",
                scope: "email",
                authorizeUrl: new System.Uri("https://m.facebook.com/dialog/oauth/"),
                redirectUrl: new System.Uri("http://m.facebook.com/connect/login_success.html"));
    
            auth.Completed+= facebookAuthCompleted;
    
            var ui = auth.GetUI(this);
            StartActivity(ui);
    

    private async void facebookAuthCompleted( object sender, AuthenticatorCompletedEventArgs e) { if (e.IsAuthenticated) { var request = new OAuth2Request("GET", new System.Uri("https://graph.facebook.com/me?fields=email,name,picture"), null, e.Account); var fbResponse = await request.GetResponseAsync(); var json = fbResponse.GetResponseText(); var fbUser= JsonValue.Parse(json); var username = fbUser["name"].ToString().Split(' '); var fbImgURL = "https://graph.facebook.com/" + fbUser["id"] + "/picture?type=large"; } }

    Facebook App settings: google play package name: com.example(dummy package) class name: com.example.Myapp (tried com.example.MainActivity here and in manifest.xml - no success too)

    Please suggest me on that what i am doing wrong here.

    Saturday, May 27, 2017 10:50 AM

All replies

  • User119 posted

    In order to help more data needs to be submitted:

    1. nuget or component and version?
    2. isUsingNativeUI = ? (seems like not using Native UI)

    Facebook App settings: google play package name: com.example(dummy package) class name: com.example.Myapp (tried com.example.MainActivity here and in manifest.xml - no success too)

    From my testing last week, those are not that important.

    Please suggest me on that what i am doing wrong here.

    Not much. Your setup (not using native UI) should be fine.

    Not logged in. Smells like redirect_url problems on server side (not sure 100%)

    Saturday, May 27, 2017 4:22 PM
  • User296687 posted

    @Miljenko Cvjetko i am using xamarin.auth component version 1.2.2.0 and as i mentioned earlier that same code is working on xamarin.iOS.

    isUsingNativeUI = ? (seems like not using Native UI) // not found in xamarin.auth getting started document and also getting error "The best overload method for OAuth2Authenticator does not have parameter named isUsingNativeUI" when adding below line. isUsingNativeUI: null

    similer issue discussed in below url: https://stackoverflow.com/questions/38750060/xamarin-auth-facebook-login-doesnt-work-vague-error-message

    Monday, May 29, 2017 9:21 AM
  • User119 posted

    @devendramaran
    Forget component. It is too old. I'm trying to pack 1.5.0 into component.

    NativeUI (isUsingNativeUI) was introduced in 1.4.0, but API changed slightly compared to version 1.3.x. More refactoring and work led to 1.5.0 which has native UI and Xamarin.Forms support.

    For iOS support everything is the same like in PCL part for Xamarin.Forms, so check Facebook implementation here:

    https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences/blob/master/Xamarin.Forms/Evolve16Labs/Portable/MainPage.ButtonFacebookClick.xaml.cs

    This is the undocumented trick for redirect_url:

    https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences/blob/master/Xamarin.Forms/Evolve16Labs/Portable/MainPage.ButtonFacebookClick.xaml.cs#L66

    Monday, May 29, 2017 10:04 AM
  • User296687 posted

    @MiljenkoCvjetko when i add xamarin.auth 1.5.0 package to my project i am getting below error in screen shot

    Monday, May 29, 2017 1:23 PM
  • User119 posted

    Try removing System.Json refernce manually.

    Thursday, June 1, 2017 9:51 AM
  • User296687 posted

    Still getting above mentioned issue.

    Tuesday, June 20, 2017 7:29 AM
  • User296687 posted

    I have created demo project (shared library) and using xamarin.auth component for Facebook login which is working in the demo project. Please see below screenshots for the components and packages (if any component or package conflict) in my main project.

    *Components: *

    *Packages *(for Google login) :

    References:

    For Google login, I am using this URL: [this is working] https://developer.xamarin.com/samples/monodroid/google-services/SigninQuickstart/

    Please suggest me what I am doing wrong here.

    Tuesday, June 20, 2017 9:54 AM
  • User296687 posted

    @MiljenkoCvjetko I have found strange behavior that xamarin.auth working in debug build when Multi-Dex option enables and also working in release build without enabling the Multi-Dex option.I am new in xamarin so It would be greate if you explain it.

    Tuesday, June 27, 2017 5:38 AM
  • User119 posted

    @Dev_Maran Cn you provide minimal sample for that?

    In depth explanation of Multi-Dex problems is something I cannot provide. Especially with lack of more information.

    Tuesday, June 27, 2017 5:41 AM