我必须访问谷歌联系人在我们的Xamarin。因此,我们已经在门户中生成了谷歌的people API密钥和客户端id,但我不知道如何在Xamarin.ios应用程序中使用API。我们需要使用API获取谷歌联系方式的详细信息。我们在谷歌文档中找到了一些.net代码,但不幸的是,它并不适用于Xamarin.ios平台。xamarin平台不支持DLL。请帮我解决这个问题。
发布于 2020-03-13 09:58:24
我用Xamarin.Auth库解决了这个问题。
Auth = new OAuth2Authenticator(
Configuration.ClientId,
string.Empty,
"https://www.googleapis.com/auth/contacts",
new Uri("https://accounts.google.com/o/oauth2/v2/auth"),
new Uri(Configuration.RedirectUrl),
new Uri("https://www.googleapis.com/oauth2/v4/token"),
isUsingNativeUI: true);
var viewController = Auth.GetUI();
PresentViewController(viewController, true, null);
Auth.Completed += Auth_Completed;
Auth.Error += Auth_Error;
private void Auth_Error(object sender, AuthenticatorErrorEventArgs e)
{
}
private void Auth_Completed(object sender, AuthenticatorCompletedEventArgs e)
{
// SFSafariViewController doesn't dismiss itself
DismissViewController(true, null);
if (e.IsAuthenticated)
{
}
}
必须在OpentUrl 12和iOS 13以上的Appdelegate.cs calss中实现SceneDelegate.cs ()方法
https://stackoverflow.com/questions/60169689
复制相似问题