我正尝试按照this link并使用Plugin.GoogleClient插件来实现Google身份验证
我已经非常仔细地遵循了所有步骤:sha键,IO上的钥匙链,Auth谷歌协议,Firebase..但是我有2个错误:
关于Andoid:我有错误:Google客户端基础异常
错误:“10:“
在IOS上:我有错误:Google客户端基础异常
错误:“读取或写入应用程序密钥链时出现问题”
按钮通过调用函数“OnLogGoogle”启动验证
下面是代码:
IGoogleClientManager _googleService = CrossGoogleClient.Current; //Plugin.GoogleClient
private async void OnLogGoogle(object senderApp, EventArgs eApp)
{
_googleService.OnLogin += OnLoginCompleted;
try
{
await _googleService.LoginAsync();
}
catch (GoogleClientSignInNetworkErrorException e)
{
await App.Current.MainPage.DisplayAlert("Error1", e.Message, "OK");
}
catch (GoogleClientSignInCanceledErrorException e)
{
await App.Current.MainPage.DisplayAlert("Error2", e.Message, "OK");
}
catch (GoogleClientSignInInvalidAccountErrorException e)
{
await App.Current.MainPage.DisplayAlert("Error3", e.Message, "OK");
}
catch (GoogleClientSignInInternalErrorException e)
{
await App.Current.MainPage.DisplayAlert("Error4", e.Message, "OK");
}
catch (GoogleClientNotInitializedErrorException e)
{
await App.Current.MainPage.DisplayAlert("Error5", e.Message, "OK");
}
catch (GoogleClientBaseException e)
{
await App.Current.MainPage.DisplayAlert("Error6", e.Message, "OK");
}
}
private void OnLoginCompleted(object sender, GoogleClientResultEventArgs<GoogleUser> loginEventArgs)
{
if (loginEventArgs.Data != null)
{
GoogleUser googleUser = loginEventArgs.Data;
/* User.Name = googleUser.Name;
User.Email = googleUser.Email;
User.Picture = googleUser.Picture;
var GivenName = googleUser.GivenName;
var FamilyName = googleUser.FamilyName;*/
// Log the current User email
Console.WriteLine("email "+ googleUser.Email);
var token = CrossGoogleClient.Current.AccessToken;
var Token = token;
}
else
{
App.Current.MainPage.DisplayAlert("Error", loginEventArgs.Message, "OK");
}
_googleService.OnLogin -= OnLoginCompleted;
}
1条答案
按热度按时间vaqhlq811#
我解决了您的android问题添加SHA-1在firebase控制台