Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

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

$
0
0

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
            }
        };`

Viewing all articles
Browse latest Browse all 58056

Trending Articles