xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
541 stars 351 forks source link

../iOS/MTOUCH: Error MT2002: Failed to resolve "System.Json.JsonValue" reference from "Xamarin.Auth, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null" (MT2002) (project_name.iOS) #234

Open DuarthVader opened 7 years ago

DuarthVader commented 7 years ago

Xamarin.Auth Issue

Version

Steps to reproduce

Release:

  1. Compile iOS project

Debug:

  1. Click play to run app in simulator.
  2. Perform any login atempt (in my app: Facebook, Google, Linked In)
  3. Fails due to error seen in screenshot below.

Platform:

Expected behaviour

Release: Compile project in order to generate .ipa Debug: Get auth login response, convert into JsonValue in order to deserialize response.

Actual behaviour

Release: Compilation error

captura de pantalla 2017-09-26 a las 13 27 40

Debug: When app is about to come back to my LoginViewModel I receive this exception:

captura de pantalla 2017-09-26 a las 13 32 24

captura de pantalla 2017-09-26 a las 13 32 40

If it helps I'm coding my project in visual studio community 2017 for Mac.

moljac commented 7 years ago

@DuarthVader Can you provide minimal sample, please?

DuarthVader commented 7 years ago

Yes. I'm using JsonValue parsing for GetResponseText()

captura de pantalla 2017-09-27 a las 10 24 05

moljac commented 7 years ago

@DuarthVader Please paste this method code here. I will try to test it with my samples.

DuarthVader commented 7 years ago

private void ClickOnFacebookBtn() { var auth = new OAuth2Authenticator( clientId: FBClientId, clientSecret: FBClientSecret, accessTokenUrl: new Uri("https://graph.facebook.com/oauth/access_token"), scope: "email", authorizeUrl: new Uri("https://www.facebook.com/v2.10/dialog/oauth"), redirectUrl: new Uri(string.Format("fb{0}://authorize", FBClientId)), getUsernameAsync: null, isUsingNativeUI: true );

        auth.Completed += Facebook_Auth_Completed;
        auth.Error += Facebook_Auth_Error;

        AuthenticationState.Authenticator = auth;

        var presenter = new OAuthLoginPresenter();
        presenter.Login(auth);
    }

private async void Facebook_Auth_Completed(object sender, AuthenticatorCompletedEventArgs e) { using (UserDialogs.Instance.Loading("Cargando...")) { var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= Facebook_Auth_Completed; authenticator.Error -= Facebook_Auth_Error; }

            if (e.IsAuthenticated)
            {
                var request = new OAuth2Request(
                    "GET",
                    new Uri("https://graph.facebook.com/v2.10/me/?fields=name,picture,location,locale,link,age_range,birthday,devices,email,first_name,last_name,gender,hometown,is_verified,languages"),
                    null,
                    e.Account
                );

                var fbResponse = await request.GetResponseAsync();
                var fbUser = JsonValue.Parse(fbResponse.GetResponseText());
                NavigateToRegister(fbUser["name"], fbUser["email"], fbUser["id"], fbUser["first_name"], (string)fbUser["last_name"] ?? "", 0);
            }
        }
    }

private void Facebook_Auth_Error(object sender, AuthenticatorErrorEventArgs e) { var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= Facebook_Auth_Completed; authenticator.Error -= Facebook_Auth_Error; }

        Debug.WriteLine("Authentication error: " + e.Message);
    }
SaturninoPimentel commented 6 years ago

I have the same issue, is there a workaround? In my case I'm using the version 1.6.0.2

Redth commented 5 years ago

This looks like a potential linker bug.

  1. With Linking set to Do Not Link, does this still occur?
  2. Have you got a reference to System.Json assembly in your project?