[Xamarin.Auth][Android][Google] How to properly use OAuth2Authenticator?

tkowalczyktkowalczyk PLMember, University ✭✭

Hi All,
I'm using my own LoginGoogleViewRendererto give ability users to authenticate with Google credentials.
My code is below everything is almost fine but after I agree with terms from Google about my data I can see some kind of alert message which appears only for miliseconds so I'm not able to see this message and then it's disappear and I can see a log info in console but similiar to this post I can't see any content. Here is the code:

    `var auth = new OAuth2Authenticator(
            clientId: "xxxxxx",
            clientSecret: "xxxx",
            scope: "openid",
            authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"),
            redirectUrl: new Uri("http://localhost"),
            accessTokenUrl: new Uri("https://accounts.google.com/o/oauth2/token"),
            getUsernameAsync: null
        );

        auth.Completed += (sender, eventArgs) =>
        {
            if (eventArgs.IsAuthenticated)
            {
                App.SuccessfulLoginAction.Invoke();
                //// Use eventArgs.Account to do wonderful things
                App.SaveToken(eventArgs.Account.Properties["access_token"]);
                //// Use for store auth service name
                App.SaveAuthService("Google");
                Console.WriteLine("User authenticated");
            }
            else
            {
                // The user cancelled
            }
        };`
Sign In or Register to comment.