Open DuarthVader opened 7 years ago
@DuarthVader Can you provide minimal sample, please?
Yes. I'm using JsonValue parsing for GetResponseText()
@DuarthVader Please paste this method code here. I will try to test it with my samples.
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);
}
I have the same issue, is there a workaround? In my case I'm using the version 1.6.0.2
This looks like a potential linker bug.
Xamarin.Auth Issue
Version
Steps to reproduce
Release:
Debug:
Platform:
[] .NET version = .NET Core Runtime: /usr/local/share/dotnet/dotnet Runtime Version: 2.0.0 SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks SDK Version: 2.0.0 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/ 5.2.0/lib/mono/msbuild/15.0/bin/Sdks
[] mono version = 5.2.0.224 (d15-3/14f2c81) (64-bit)
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
Debug: When app is about to come back to my LoginViewModel I receive this exception:
If it helps I'm coding my project in visual studio community 2017 for Mac.