I want to let user connect to my Xamarin Forms app with their Google account. I have been following this tutorial: https://www.syncfusion.com/blogs/post/google-login-integration-in-xamarin-forms-a-complete-guide.aspx
What should go into redirectUrl value? Now I have '400 error: invalid_request'. I probably should register that page somewhere? And what that page should be? I would like to get user info after login and redirect them to main app page (HomePage()).
I have this code:
Xamarin.Auth.OAuth2Authenticator authenticator = null;
private void SignInGoogleClicked(object sender, EventArgs e)
{
authenticator
= new Xamarin.Auth.OAuth2Authenticator
(
clientId: "498923533154-uefrhbk3i9v7nqd7lep9lqb85u783m7v.apps.googleusercontent.com",
scope: "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-healthcare",
authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"),
redirectUrl:
new Func<Uri>
(
() =>
{
string uri = null;
switch (Xamarin.Forms.Device.RuntimePlatform)
{
case "Android":
uri =
"com.xamarin.traditional.standard.samples.oauth.providers.android:/oauth2redirect"
//"com.googleusercontent.apps.1093596514437-uefrhbk3i9v7nqd7lep9lqb85u783m7v:/oauth2redirect"
;
break;
case "iOS":
uri =
"com.xamarin.traditional.standard.samples.oauth.providers.ios:/oauth2redirect"
//"com.googleusercontent.apps.1093596514437-cajdhnien8cpenof8rrdlphdrboo56jh:/oauth2redirect"
;
break;
case "Windows":
uri =
"com.xamarin.traditional.standard.samples.oauth.providers.ios:/oauth2redirect"
//"com.googleusercontent.apps.1093596514437-cajdhnien8cpenof8rrdlphdrboo56jh:/oauth2redirect"
;
break;
}
return new Uri(uri);
}
).Invoke(),
getUsernameAsync: null,
isUsingNativeUI: false
)
{
AllowCancel = true,
};
NavigateLoginPage();
}
Xamarin.Auth.XamarinForms.AuthenticatorPage login_page = null;
private void NavigateLoginPage()
{
login_page = new Xamarin.Auth.XamarinForms.AuthenticatorPage()
{
Authenticator = authenticator,
};
Navigation.PushAsync(login_page);
}