I have scoured the web trying to get an answer for this and I have found many but none of them work. Google requires that the authentication happens in the browser and not in a WebView. I have implemented it like this for Android:
var activity = this.Context as Activity;
var auth = new OAuth2Authenticator(
clientId: "xxxx.apps.googleusercontent.com",
scope: "",
authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"),
redirectUrl: new Uri("myredirecturi"));
auth.Completed += (sender, eventArgs) => {
if (eventArgs.IsAuthenticated)
{
App.SuccessfulLoginAction.Invoke();
App.SaveToken(eventArgs.Account.Properties["access_token"]);
}
};
activity.StartActivity(auth.GetUI(activity));
And like this for iOS:
var auth = new OAuth2Authenticator(
clientId: "xxxx.apps.googleusercontent.com", // your OAuth2 client id
scope: "",
authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"),
redirectUrl: new Uri("myredirecturi"));
auth.Completed += (sender, eventArgs) =>
{
App.SuccessfulLoginAction.Invoke();
if (eventArgs.IsAuthenticated)
{
App.SaveToken(eventArgs.Account.Properties["access_token"]);
}
PresentViewController(auth.GetUI(), true, null);
};
But this does exactly what I don't want it to do (opens a WebView) and every single answer I have found does exactly this. How do I go about doing it correctly so that the browser opens and then returns to my app when it is done?
Furthermore, I know the scope specifies what I want to do, and in this case it is just a sign-in, but I have yet to find an example of what to actually put in there.
Any example will be really appreciated.