Пример #1
0
        void handleSignInResult(GoogleSignInResult result)
        {
            //Log.d (TAG, "handleSignInResult:" + result.isSuccess ());
            if (result.IsSuccess)
            {
                // Signed in successfully, show authenticated UI.
                GoogleSignInAccount user = result.SignInAccount;

                if (user != null)
                {
                    Log.Debug($"user.Account.Name: {user.Account.Name}");
                    Log.Debug($"acct.DisplayName: {user.DisplayName}");
                    Log.Debug($"acct.Email: {user.Email}");
                    Log.Debug($"acct.FamilyName: {user.FamilyName}");
                    Log.Debug($"acct.GivenName: {user.GivenName}");
                    Log.Debug($"acct.GrantedScopes: {string.Join (",", user.GrantedScopes)}");
                    Log.Debug($"acct.Id: {user.Id}");
                    Log.Debug($"acct.IdToken: {user.IdToken}");
                    Log.Debug($"acct.PhotoUrl: {user.PhotoUrl}");
                    Log.Debug($"acct.ServerAuthCode: {user.ServerAuthCode}");

                    var details = new ClientAuthDetails
                    {
                        ClientAuthProvider = ClientAuthProviders.Google,
                        Username           = user.DisplayName,
                        Email     = user.Email,
                        Token     = user.IdToken,
                        AuthCode  = user.ServerAuthCode,
                        AvatarUrl = user.PhotoUrl.ToString()
                    };

                    ClientAuthManager.Shared.SetClientAuthDetails(details);

                    Finish();
                }
            }
            else
            {
                // Signed out, show unauthenticated UI.
                Log.Error($"Google SingIn failed with code:{result.Status}");
            }
        }
Пример #2
0
        public void DidSignIn(SignIn signIn, GoogleUser user, NSError error)
        {
            if (error == null && user != null)
            {
                // Perform any operations on signed in user here.
                var userId      = user.UserID;                 // For client-side use only!
                var idToken     = user.Authentication.IdToken; // Safe to send to the server
                var accessToken = user.Authentication.AccessToken;
                var serverAuth  = user.ServerAuthCode;
                var fullName    = user.Profile.Name;
                var givenName   = user.Profile.GivenName;
                var familyName  = user.Profile.FamilyName;
                var email       = user.Profile.Email;
                var imageUrl    = user.Profile.GetImageUrl(64);
                // ...;
                Log.Debug($"\n\tuserId: {userId},\n\tidToken: {idToken},\n\taccessToken: {accessToken},\n\tserverAuth: {serverAuth},\n\tfullName: {fullName},\n\tgivenName: {givenName},\n\tfamilyName: {familyName},\n\temail: {email},\n\timageUrl: {imageUrl},\n\t");

                var details = new ClientAuthDetails
                {
                    ClientAuthProvider = ClientAuthProviders.Google,
                    Username           = user.Profile?.Name,
                    Email     = user.Profile?.Email,
                    Token     = user.Authentication?.IdToken,
                    AuthCode  = user.ServerAuthCode,
                    AvatarUrl = user.Profile.GetImageUrl(AvatarSize * (nuint)UIScreen.MainScreen.Scale)?.ToString()
                };

                ClientAuthManager.Shared.SetClientAuthDetails(details);

                DismissViewController(true, null);
            }
            else
            {
                Log.Error(error?.LocalizedDescription);
            }
        }