Exemplo n.º 1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (requestCode == 99) // google oauth
            {
                GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
                if (result.IsSuccess)
                {
                    GoogleSignInAccount account = result.SignInAccount;

                    var properties = new Dictionary <string, string>();
                    properties.Add("access_token", account.IdToken);

                    ShinyHost.Resolve <IOAuthService>().OnOAuthComplete(null,
                                                                        new AuthenticatorCompletedEventArgs(new Account(account.DisplayName, properties)));
                }
                else
                {
                    if (result.Status.StatusCode == 12501)
                    {
                        ShinyHost.Resolve <IOAuthService>().OnOAuthError(null, null);
                    }
                    else
                    {
                        ShinyHost.Resolve <IOAuthService>().OnOAuthError(null, new AuthenticatorErrorEventArgs($"Google OAuth ErrorCode: {result.Status.StatusCode}"));
                    }
                }
            }
            else
            {
                InAppBillingImplementation.HandleActivityResult(requestCode, resultCode, data);
            }
        }
Exemplo n.º 2
0
        async public void HandleSignInResult(GoogleSignInResult result)
        {
            if (result.IsSuccess)
            {
                // Signed in successfully, show authenticated UI.
                var acct = result.SignInAccount;
                TitleTextView.Text = acct.DisplayName;

                ImageView.SetImage(acct.PhotoUrl.ToString(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, "Google", WebImageView.DefaultCircleTransformation);

                var outlet = new Outlet();
                outlet.Name   = acct.DisplayName;
                outlet.Handle = acct.Id;
                outlet.Type   = Outlet.outlet_type_google;
                RealmServices.SaveOutlet(outlet);

                await Task.Delay(TimeSpan.FromSeconds(2));

                var activity = Activity as BaseActivity;
                activity?.PopFragmentOverUntil(typeof(MyOutletsRecyclerViewFragment));
            }
            else
            {
            }
        }
Exemplo n.º 3
0
 protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     Log.Debug(TAG, "Sign in result with result code: " + resultCode);
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode == 1)
     {
         if (resultCode == Result.Ok)
         {
             GoogleSignInResult res = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
             if (res.IsSuccess)
             {
                 GoogleSignInAccount acct = res.SignInAccount;
                 Log.Debug(TAG, "id:" + acct.Id + " tokenId:" + acct.IdToken);
             }
             else
             {
                 AlertDialog.Builder alg = new AlertDialog.Builder(this);
                 alg.SetTitle("Sign in failed");
                 alg.Show();
             }
         }
         else
         {
             AlertDialog.Builder alg = new AlertDialog.Builder(this);
             alg.SetTitle("Sign in failed");
             alg.Show();
         }
     }
 }
Exemplo n.º 4
0
        private async void HandleSignInResult(GoogleSignInResult signInResult)
        {
            try
            {
                if (signInResult == null || !signInResult.IsSuccess || signInResult.SignInAccount == null)
                {
                    _googleApiClient.Disconnect();
                    _loginTask.TrySetResult(false);
                    return;
                }

                // Create authentication token
                var idToken = signInResult.SignInAccount.IdToken;
                var token   = new JObject {
                    { "id_token", idToken }
                };

                // Login to Azure Mobile Services
                var mobileServiceClient = ServiceLocator.Current.GetInstance <IMobileServiceClient>();
                var user = await mobileServiceClient
                           .LoginAsync(MobileServiceAuthenticationProvider.Google, token)
                           .ConfigureAwait(true);

                _loginTask.TrySetResult(user != null);
            }
            catch (Exception exception)
            {
                _loginTask.TrySetException(exception);
            }
            finally
            {
                _isConnecting = false;
            }
        }
Exemplo n.º 5
0
        async void ProcessSignInResult(Intent data)
        {
            GoogleSignInResult signInResult = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);

            if (signInResult.IsSuccess)
            {
                AuthCredential credential = GoogleAuthProvider.GetCredential(signInResult.SignInAccount.IdToken, null);
                try
                {
                    IAuthResult authResult = await FirebaseAuth_.SignInWithCredentialAsync(credential);

                    FirebaseUser user = authResult.User;

                    User.myInfo.PhotoPath = signInResult.SignInAccount.PhotoUrl.ToString();

                    User.Uid             = signInResult.SignInAccount.Id;
                    User.Token           = signInResult.SignInAccount.IdToken;
                    User.myInfo.NickName = signInResult.SignInAccount.DisplayName;

                    StartActivity(new Intent(Application.Context, typeof(MainActivity)));
                }
                catch (Exception ex)
                {
                    //    new Handler(MainLooper).Post(() => new Android.App.AlertDialog.Builder(this).SetMessage("var_TeamRecord 등록 실패\n\n" + ex).Show());
                }
            }
            else
            {
                StartActivity(new Intent(Application.Context, typeof(MainActivity)));
            }
        }
Exemplo n.º 6
0
        public void OnAuthCompleted(GoogleSignInResult result)
        {
            GoogleUser googleUser = new GoogleUser();

            if (result.IsSuccess)
            {
                Task.Factory.StartNew(() => {
                    if (result.SignInAccount.Account == null)
                    {
                        MessagingCenter.Send <string>("access token bilgisi alınamadı", "NoInternet");
                    }
                    var accessToken        = GoogleAuthUtil.GetToken(Android.App.Application.Context, result.SignInAccount.Email, $"oauth2:{Scopes.Email} {Scopes.Profile}");
                    googleUser.AccessToken = accessToken;
                    MessagingCenter.Send <string>(accessToken, "googleAndroidAccessToken");
                });
                GoogleSignInAccount accountt = result.SignInAccount;
                googleUser.Email       = accountt.Email;
                googleUser.Name        = accountt.GivenName;
                googleUser.Surname     = accountt.FamilyName;
                googleUser.AccessToken = accountt.IdToken;
                //googleUser.Token = accountt.IdToken;

                googleUser.Picture = new Uri((accountt.PhotoUrl != null ? $"{accountt.PhotoUrl}" : $"https://autisticdating.net/imgs/profile-placeholder.jpg"));
                _onLoginComplete?.Invoke(googleUser, string.Empty);
            }
            else
            {
                _onLoginComplete?.Invoke(null, "An error occured!");
            }
        }
Exemplo n.º 7
0
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            Log.Debug(TAG, "onActivityResult:" + requestCode + ":" + resultCode + ":" + data);
            if (CallbackManager != null)
            {
                CallbackManager.OnActivityResult(requestCode, (int)resultCode, data);
            }
            if (requestCode == RC_SIGN_IN)
            {
                IsLogin_InProgress(false);
                GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
                if (result.IsSuccess)
                {
                    GoogleSignInAccount userAccount = result.SignInAccount;
                    var success = await FirebaseAuthHelper.FirebaseAuthWithGoogle(FirebaseAuth, userAccount);

                    if (success)
                    {
                        Intent mainactivityIntent = new Intent(this, typeof(MainActivity));
                        StartActivity(mainactivityIntent);
                        Finish();
                    }
                }
            }
        }
Exemplo n.º 8
0
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            try
            {
                if (requestCode == 1)
                {
                    GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
                    if (result.IsSuccess)
                    {
                        GoogleSignInAccount account = result.SignInAccount;
                        string gClientId            = AppController.Globals.GoogleClientId_Android;
                        string gEmail = account.Email;
                        string gToken = account.IdToken;

                        _cts0 = new CancellationTokenSource();
                        AppController.LoginUser(_cts0, gClientId, gEmail, gToken,
                                                (d) =>
                        {
                            AppController.Settings.LastLoginUserIdUsed   = d.UserId;
                            AppController.Settings.LastLoginUsernameUsed = _email;
                            AppController.Settings.AuthAccessToken       = d.AuthAccessToken;
                            AppController.Settings.AuthExpirationDate    = d.AuthExpirationDate.GetValueOrDefault().ToLocalTime();
                            AppController.Settings.GoogleSignedIn        = true;

                            var f = new GimmicksFragment();
                            this.FragmentManager.BeginTransaction()
                            .AddToBackStack("BeforeGimmicksFragment")
                            .Replace(Resource.Id.ContentLayout, f, "GimmicksFragment")
                            .Commit();
                        },
                                                (error) =>
                        {
                            Toast.MakeText(this.Activity.Application, error, ToastLength.Long).Show();
                        },
                                                () =>
                        {
                            ((MainActivity)this.Activity).UnblockUI();
                        });
                    }
                    else
                    {
                        ((MainActivity)this.Activity).UnblockUI();

                        Toast.MakeText(this.Activity.Application, "Unable to login with Google!", ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception ex)
            {
                ((MainActivity)this.Activity).UnblockUI();

                Toast.MakeText(this.Activity.ApplicationContext, "Error logging with Google!", ToastLength.Long).Show();
            }
            finally
            {
                // Nothing to do
            }
        }
Exemplo n.º 9
0
        public async void HandleSignInResult(GoogleSignInResult result)
        {
            Log.Debug(TAG, "handleSignInResult:" + result.IsSuccess);
            if (result.IsSuccess)
            {
                // Signed in successfully, show authenticated UI.
                var acct = result.SignInAccount;
                mStatusTextView.Text = string.Format(GetString(Resource.String.signed_in_fmt), acct.DisplayName);
                UpdateUI(true);

                // Get the latitude and longitude entered by the user and create a query.
                // Note that input error checking is ignored here.

                string fullname = acct.DisplayName;
                string email    = acct.Email;

                string url = "http://35.22.42.160:3000/users?fullname=" + fullname + "&email=" + email;
                Console.Out.Write(url);
                // Fetch the weather information asynchronously, parse the results,
                // then update the screen:
                JsonValue json = await FetchDBAsync(url, "GET");

                Intent intent = new Intent(this, typeof(Resources.layout.Activity1));
                intent.PutExtra("fullname", Convert.ToString(fullname));
                intent.PutExtra("email", Convert.ToString(email));
                StartActivity(intent);
            }
            else
            {
                // Signed out, show unauthenticated UI.
                UpdateUI(false);
            }
        }
Exemplo n.º 10
0
        private GoogleProfile HandleSignInResult(GoogleSignInResult result)
        {
            GoogleProfile googleProfile = null;

            if (result.IsSuccess)
            {
                // Signed in successfully, show authenticated UI.
                GoogleSignInAccount acct = result.SignInAccount;
                googleProfile = new GoogleProfile()
                {
                    GivenName  = acct.GivenName,
                    FamilyName = acct.FamilyName,
                    Email      = acct.Email,
                    Id         = acct.Id
                };

                //HttpClient client = new HttpClient();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("The resul was not success");
            }

            return(googleProfile);
        }
Exemplo n.º 11
0
        protected override void OnActivityResult(int requestCode, Result resultVal, Intent data)
        {
            if (requestCode == AndroidHalProxy.VOICE)
            {
                if (resultVal == Result.Ok)
                {
                    var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults);
                    if (matches.Count != 0)
                    {
                        this.halProxy.OnRecognizedText(matches, new ErrorResult());
                    }
                    else
                    {
                        this.halProxy.OnRecognizedText(new string[] { "No speech was recognised" }, new ErrorResult(ErrorCodes.InvalidLanguage, "No speech was recognised"));
                    }
                }
                else if (resultVal == Result.Canceled)
                {
                    this.halProxy.OnRecognizedText(new string[] { "cancelled" }, new ErrorResult(ErrorCodes.Cancelled, "Cancelled"));
                }
            }

            base.OnActivityResult(requestCode, resultVal, data);

            if (requestCode == RC_SIGN_IN)
            {
                GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
                var profile = HandleSignInResult(result);
            }
        }
Exemplo n.º 12
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (requestCode == PickImageId)
            {
                if ((resultCode == Result.Ok) && (data != null))
                {
                    Android.Net.Uri  uri    = data.Data;
                    System.IO.Stream stream = ContentResolver.OpenInputStream(uri);
                    PickImageTaskCompletionSource.SetResult(stream);
                }
                else
                {
                    PickImageTaskCompletionSource.SetResult(null);
                }
            }
            if (requestCode == 1)
            {
                GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
                if (result.IsSuccess)
                {
                    GoogleSignInAccount account = result.SignInAccount;

                    LoginWithFirebase(account);
                }
            }
        }
Exemplo n.º 13
0
        async void ProcessSignInResult(Intent data)
        {
            GoogleSignInResult signInResult = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);

            if (signInResult.IsSuccess)
            {
                AuthCredential credential = GoogleAuthProvider.GetCredential(signInResult.SignInAccount.IdToken, null);
                try
                {
                    User.PhotoPath = signInResult.SignInAccount.PhotoUrl.ToString();

                    User.Uid      = signInResult.SignInAccount.Id;
                    User.Token    = signInResult.SignInAccount.IdToken;
                    User.NickName = signInResult.SignInAccount.DisplayName;

                    IAuthResult authResult = await FirebaseAuth_.SignInWithCredentialAsync(credential);

                    FirebaseUser user = authResult.User;
                }
                catch (Exception ex)
                {
                    //                    new Handler(MainLooper).Post(() => new AlertDialog.Builder(this).SetMessage("파이어베이스 등록 실패\n\n" + ex).Show());
                }
            }
            else
            {
            }
        }
Exemplo n.º 14
0
 /// <summary>
 ///     Called when [authentication completed].
 /// </summary>
 /// <param name="result">The result.</param>
 public void OnAuthCompleted(GoogleSignInResult result)
 {
     if (result.IsSuccess)
     {
         var account = result.SignInAccount;
         OnLoginComplete?.Invoke(
             new AppUser
         {
             Provider = "Google",
             Id       = account.Id,
             Token    = account.IdToken,
             Name     = account.DisplayName,
             Email    = account.Email,
             Picture  = new Uri(
                 account.PhotoUrl != null
                              ? $"{account.PhotoUrl}"
                              : $"")
         },
             string.Empty);
     }
     else
     {
         OnLoginComplete?.Invoke(null, "An error occurred!");
     }
 }
Exemplo n.º 15
0
 public void FoundResult(GoogleSignInResult result)
 {
     if (tcsSignIn != null && !tcsSignIn.Task.IsCompleted)
     {
         tcsSignIn.TrySetResult(result);
     }
 }
Exemplo n.º 16
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
        {
            base.OnActivityResult(requestCode, resultCode, intent);
            if (requestCode == 1)
            {
                GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(intent);
                GoogleManager.Instance.OnAuthCompleted(result);
            }

            else if (requestCode == PickImageId)
            {
                if ((resultCode == Result.Ok) && (intent != null))
                {
                    Android.Net.Uri uri    = intent.Data;
                    Stream          stream = ContentResolver.OpenInputStream(uri);

                    // Set the Stream as the completion of the Task
                    PickImageTaskCompletionSource.SetResult(stream);
                }
                else
                {
                    PickImageTaskCompletionSource.SetResult(null);
                }
            }
        }
Exemplo n.º 17
0
        private async void HandleSignInResult(GoogleSignInResult result)
        {
            if (result.IsSuccess)
            {
                // Signed in successfully, show authenticated UI.
                ProgressDialog      progressDialog = ProgressDialog.Show(this, "", "Retrieving profile data", true);
                GoogleSignInAccount acct           = result.SignInAccount;
                await MeritMoneyBrain.SingInWithGoogle(acct.IdToken);

                Profile profile = await MeritMoneyBrain.GetProfile();

                Intent returnIntent = new Intent();
                returnIntent.PutExtra(GetString(Resource.String.LogIn), true);
                SetResult(Result.Ok, returnIntent);
                await new SaveData().Execute(profile).GetAsync();
                progressDialog.Dismiss();
                Finish();
                //updateUI(true);
            }
            else
            {
                // Signed out, show unauthenticated UI.
                //updateUI(false);
            }
        }
Exemplo n.º 18
0
 public void setSignInResult(GoogleSignInResult result)
 {
     if (signInResultSource != null && !signInResultSource.Task.IsCompleted)
     {
         signInResultSource.TrySetResult(result);
     }
 }
Exemplo n.º 19
0
 private void HandleSignInResult(GoogleSignInResult result)
 {
     if (result.IsSuccess)
     {
         var accountDetails = result.SignInAccount;
     }
 }
Exemplo n.º 20
0
        public void HandleSignInResult(GoogleSignInResult result)
        {
            Log.Debug(TAG, "handleSignInResult:" + result.IsSuccess);


            if (result.IsSuccess)
            {
                idToken = result.SignInAccount.IdToken;
                Console.WriteLine("Token: " + idToken);


                Intent nextActivity = new Intent(this, typeof(JakesMainActivity));
                nextActivity.PutExtra("token", idToken);
                nextActivity.PutExtra("next", nextScreen);
                //nextActivity.SetFlags(ActivityFlags.ReorderToFront);
                StartActivity(nextActivity);


                // TODO: change UI here

                // Signed in successfully, show authenticated UI.
                var acct = result.SignInAccount;

                mStatusTextView.Text = string.Format(GetString(Resource.String.signed_in_fmt), acct.DisplayName);
                UpdateUI(true);
            }
            else
            {
                // Signed out, show unauthenticated UI.
                UpdateUI(false);
            }
        }
Exemplo n.º 21
0
        async void HandleSignInResult(GoogleSignInResult result)
        {
            if (result.IsSuccess)
            {
                if (App.account != null)
                {
                    await App.accountStore.DeleteAsync(App.account, App.APP_NAME);
                }

                var googleSignInAccount = result.SignInAccount;
                var dic = new Dictionary <string, string>
                {
                    { "IdToken", googleSignInAccount.IdToken }
                };

                App.account = new Xamarin.Auth.Account(googleSignInAccount.DisplayName, dic);
                await App.accountStore.SaveAsync(App.account, App.APP_NAME + Properties.Resources.GoogleAuthorization);

                MessagingCenter.Send("!", "Done");
            }
            else
            {
                Log.Debug("HandleSignInResult", result.Status?.ToString());
            }
        }
 public void OnAuthCompleted(GoogleSignInResult result)
 {
     if (result.IsSuccess)
     {
         var account = result.SignInAccount;
         if (account != null)
         {
             _loginResult = new LoginResult
             {
                 UserId    = account.Id,
                 FirstName = account.DisplayName,
                 Email     = account.Email,
                 ImageUrl  = new Uri(account.PhotoUrl != null
                     ? $"{account.PhotoUrl}"
                     : "https://autisticdating.net/imgs/profile-placeholder.jpg").ToString(),
                 Token       = account.IdToken,
                 LoginSource = LoginSource.Google,
                 LoginState  = LoginState.Success
             }
         }
         ;
         SetResult(_loginResult);
     }
     else
     {
         SetResult(new LoginResult {
             LoginState = LoginState.Failed, ErrorString = "An error occured!"
         });
     }
 }
Exemplo n.º 23
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}");

                    ClientAuthManager.Shared.SetClientAuthDetails(user.GetAuthDetails());
                    Finish();
                }
            }
            else
            {
                // Signed out, show unauthenticated UI.
                Log.Debug($"Google SingIn failed with code:{result.Status}");
            }
        }
Exemplo n.º 24
0
		private static void HandleSignInResult(GoogleSignInResult result)
		{
            if (result.IsSuccess)
                OnSuccess?.Invoke(result.Status);
            else if (!result.IsSuccess)
                OnFailure?.Invoke(result.Status);
		}
Exemplo n.º 25
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == RC_SIGN_IN)
     {
         mGoogleSignInResult = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
         handleSignInResult();
     }
 }
Exemplo n.º 26
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode == 1)
     {
         GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
         GoogleManager.Instance.OnAuthCompleted(result);
     }
 }
Exemplo n.º 27
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode == 1)
     {
         GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
         AndroidGoogleService.Instance.OnAuthCompleted(result, resultCode);
     }
 }
Exemplo n.º 28
0
 protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode == RC_SIGN_IN)
     {
         GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
         handleSignInResult(result);
     }
 }
Exemplo n.º 29
0
        public void HandleSignIn(GoogleSignInResult result)
        {
            GoogleSignInAccount account = null;

            if (result.IsSuccess)
            {
                account = result.SignInAccount;
            }
        }
Exemplo n.º 30
0
 internal void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     InAppBillingImplementation.HandleActivityResult(requestCode, resultCode, data);
     if (requestCode == 1)
     {
         GoogleSignInResult result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
         OnAuthCompleted(result); // todo later
     }
 }
Exemplo n.º 31
0
 public void FoundResult(GoogleSignInResult result)
 {
     if (tcsSignIn != null && !tcsSignIn.Task.IsCompleted)
         tcsSignIn.TrySetResult(result);
 }