I am working in a xmarine android c# project. where I want to access google contact from my c# android app. For This I have used the below mentioned link: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/authentication/oauth I am unable to get access_token in OnAuthCompleted method. How can I do so?
I am giving my code below for better understanding.
public void googleAuthentication()
{
var authenticator = 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);
authenticator.Completed += OnAuthCompleted;
authenticator.Error += Authenticator_Error;
var a = authenticator.GetUI(this);
StartActivity(a);
}
also I have added another activity in my project for custom URL scheme as per the above link. but it is not working, code is as follows:
[Activity(Label = "CustomUrlSchemeInterceptorActivity", NoHistory = true, LaunchMode = LaunchMode.SingleTop)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataSchemes = new[] { "com.googleusercontent.apps.94221532031-00o4meh3gmmq4g8r3ersa6m3oskmbkat" },
DataPath = "/oauth2redirect")]
public class CustomUrlSchemeInterceptorActivity : Activity
{
public static OAuth2Authenticator Auth;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
var uri = new Uri(Intent.Data.ToString());
// Load redirectUrl page
CustomUrlSchemeInterceptorActivity.Auth.OnPageLoading(uri);
Finish();
}
}
please help me how to get access_token in async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e) method

