protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); signinButton = (Button)FindViewById(Resource.Id.signinButton); displayNameText = (TextView)FindViewById(Resource.Id.displayNameText); emailText = (TextView)FindViewById(Resource.Id.emailText); photourlText = (TextView)FindViewById(Resource.Id.photourlText); phoneText = (TextView)FindViewById(Resource.Id.phoneText); signinButton.Click += SigninButton_Click; gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("148409925853-g729sb67d8e9uh72pn8ocvl3n93bocat.apps.googleusercontent.com") .RequestEmail() .Build(); googleApiClient = new GoogleApiClient.Builder(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleApiClient.Connect(); firebaseAuth = GetFirebaseAuth(); UpdateUI(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); FindViewById(Resource.Id.sign_in_button).SetOnClickListener(this); // Set title for action bar var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.Title = "Login"; SetSupportActionBar(toolbar); // Configure sign-in to request the user's ID, email address GoogleSignInOptions gso = auth.GetGoogleSignInOptions(); // Build a GoogleApiClient with access to the Google Sign-In API mGoogleApiClient = new GoogleApiClient.Builder(this) .EnableAutoManage(this, this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .Build(); // Set the dimensions of the sign-in button. var signInButton = FindViewById <SignInButton>(Resource.Id.sign_in_button); signInButton.SetSize(SignInButton.SizeStandard); }
internal GoogleClientManager() { if (CurrentActivity == null) { throw new GoogleClientNotInitializedErrorException(GoogleClientBaseException.ClientNotInitializedErrorMessage); } var gopBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail(); if (!string.IsNullOrWhiteSpace(_serverClientId)) { gopBuilder.RequestServerAuthCode(_serverClientId, false); } if (!string.IsNullOrWhiteSpace(_clientId)) { gopBuilder.RequestIdToken(_clientId); } foreach (var s in _initScopes) { gopBuilder.RequestScopes(new Scope(s)); } GoogleSignInOptions googleSignInOptions = gopBuilder.Build(); // Build a GoogleSignInClient with the options specified by gso. mGoogleSignInClient = GoogleSignIn.GetClient(CurrentActivity, googleSignInOptions); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; VKSdk.CustomInitialize(this, 7559603, "5.52"); base.OnCreate(savedInstanceState); global::Rg.Plugins.Popup.Popup.Init(this, savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Plugin.Media.CrossMedia.Current.Initialize(); global::Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); CreateNotificationChannel(); app = new App(); LoadApplication(app); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("270394628656-4ri5kuhj5h2uvk2mmume2u2rblligt4n.apps.googleusercontent.com") .RequestEmail() .Build(); googleApiClient = new GoogleApiClient.Builder(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .Build(); googleApiClient.Connect(); FireAuth = GetFirebaseAuth(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_login); this.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); this.Window.ClearFlags(WindowManagerFlags.TranslucentStatus); this.Window.SetStatusBarColor(Color.ParseColor("#204060")); progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar); googlebutton = FindViewById <Button>(Resource.Id.googlebutton); googlebutton.Click += Googlebutton_Click; facebookbutton = FindViewById <Button>(Resource.Id.facebookbutton); facebookbutton.Click += Facebookbutton_Click; fb_dummybuttton = FindViewById <LoginButton>(Resource.Id.fb_dummybuttton); fb_dummybuttton.SetReadPermissions(new List <string> { "public_profile", "email" }); callbackManager = CallbackManagerFactory.Create(); fb_dummybuttton.RegisterCallback(callbackManager, this); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn).RequestIdToken("787402240794-prndui4ntngl1je2lglu46lev1esogsi.apps.googleusercontent.com") .RequestEmail().Build(); googleApiClient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleApiClient.Connect(); firebaseAuth = AppDataHelper.GetFirebaseAuth(); prefs = PreferenceManager.GetDefaultSharedPreferences(this); AppDataHelper.editor = prefs.Edit(); }
private void InicioGPlusStart() { mGoogleSigninOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail() .RequestProfile() .Build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .EnableAutoManage(this, this) .AddApi(Auth.GOOGLE_SIGN_IN_API, mGoogleSigninOptions) .Build(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.googleSignIn); nextScreen = Intent.GetStringExtra("next"); signOut = Intent.GetStringExtra("signOut"); if (signOut == "true") { try { RevokeAccess(); } catch (Exception) { Console.WriteLine("Tried to log user out but no user was logged in?"); } } mStatusTextView = FindViewById <TextView>(Resource.Id.status); FindViewById(Resource.Id.sign_in_button).SetOnClickListener(this); FindViewById(Resource.Id.sign_out_button).SetOnClickListener(this); FindViewById(Resource.Id.disconnect_button).SetOnClickListener(this); // [START configure_signin] // Configure sign-in to request the user's ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("194187796125-1tk73jfb7ors490aj61ehh9kaos1ie5d.apps.googleusercontent.com") .RequestEmail() .Build(); // [END configure_signin] // [START build_client] // Build a GoogleApiClient with access to the Google Sign-In API and the // options specified by gso. mGoogleApiClient = new GoogleApiClient.Builder(this) .EnableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .Build(); // [END build_client] // [START customize_button] // Set the dimensions of the sign-in button. var signInButton = FindViewById <SignInButton>(Resource.Id.sign_in_button); signInButton.SetSize(SignInButton.SizeStandard); // [END customize_button] }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken(AppController.Globals.GoogleClientId_Android) .RequestEmail() .Build(); _gapi = new GoogleApiClient.Builder(this.Context) .EnableAutoManage(this.Activity, this) .AddApi(Android.Gms.Auth.Api.Auth.GOOGLE_SIGN_IN_API, _gso) .AddScope(new Scope(Scopes.Profile)) .Build(); }
internal GoogleClientManager() { if (CurrentActivity == null) { GoogleClientErrorEventArgs errorEventArgs = new GoogleClientErrorEventArgs(); Exception exception = null; errorEventArgs.Error = GoogleClientErrorType.SignInInternalError; errorEventArgs.Message = GoogleClientBaseException.SignInInternalErrorMessage; exception = new GoogleClientSignInInternalErrorException(); _loginTcs.TrySetException(exception); } var gopBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail(); if (!string.IsNullOrWhiteSpace(_serverClientId)) { gopBuilder.RequestServerAuthCode(_serverClientId, false); } if (!string.IsNullOrWhiteSpace(_clientId)) { gopBuilder.RequestIdToken(_clientId); } foreach (var s in _initScopes) { gopBuilder.RequestScopes(new Scope(s)); } GoogleSignInOptions googleSignInOptions = gopBuilder.Build(); var googleApiClientBuilder = new GoogleApiClient.Builder(Application.Context) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions); foreach (var a in _initApis) { googleApiClientBuilder.AddApi(a); } GoogleApiClient = googleApiClientBuilder.Build(); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.FormsMaps.Init(this, savedInstanceState); Xamarin.FormsGoogleMaps.Init(this, savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Instance = this; LoadApplication(new App()); if (Connectivity.NetworkAccess != NetworkAccess.Internet) { return; } //SetContentView(Resource.Layout.main) // Intent intent = new Intent(); // intent.SetClass(this,PrevActivity); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("вставьте свой токен :)") .RequestEmail() .Build(); googleApiClient = new GoogleApiClient.Builder(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleApiClient.Connect(); firebaseAuth = GetFirebaseAuth(); string loginCheck = Preferences.Get("userName", "default"); //string locationCheck = Preferences.Get("location", "epty"); //if (!Preferences.ContainsKey("location")) // Preferences.Set("location", "msk"); if (Preferences.ContainsKey("location")) { string[] str = Preferences.Get("location", "empty").Split(','); ContentManager.Locations = str.ToList(); } if (loginCheck == "empty" || loginCheck == "default") { SigninButton(); } Dexter.WithActivity(this) .WithPermission(Manifest.Permission.AccessFineLocation) .WithListener(this) .Check(); }
public void Initialize() { // Configure sign-in to request the user's ID, email address, and basic profile. ID and // basic profile are included in DEFAULT_SIGN_IN. gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail() .Build(); // Build a GoogleApiClient with access to GoogleSignIn.API and the options above. googleApiClient = new GoogleApiClient.Builder(Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity as FragmentActivity) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .EnableAutoManage(Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity as FragmentActivity, this) //.AddScope(PlusClass.ScopePlusLogin) //.AddScope(PlusClass.ScopePlusProfile) .Build(); }
public async Task <User> LoginGoogle() { gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("216415232228-vsuoihg6h9i13p7vl0kdosaj6jl84k67.apps.googleusercontent.com") .RequestEmail() .Build(); client = new GoogleApiClient.Builder(MainActivity.ActivityContext) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .Build(); client.Connect(); firebaseAuth = FirebaseAuth.Instance; GoogleSignInResult result = await OpenGoogleLogin(); if (result.IsSuccess) { GoogleSignInAccount account = result.SignInAccount; var resultado = await LoginWithFirebase(account); if (resultado) { User user = new User(); user.FirstName = account.GivenName; user.LastName = account.FamilyName; user.Email = firebaseAuth.CurrentUser.Email; return(user); } else { return(new User()); } } else { return(new User()); } }
internal GoogleClientManager() { if (CurrentActivity == null) { throw new GoogleClientNotInitializedErrorException(GoogleClientBaseException.ClientNotInitializedErrorMessage); } var gopBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail(); if (!string.IsNullOrWhiteSpace(_serverClientId)) { gopBuilder.RequestServerAuthCode(_serverClientId, false); } if (!string.IsNullOrWhiteSpace(_clientId)) { gopBuilder.RequestIdToken(_clientId); } foreach (var s in _initScopes) { gopBuilder.RequestScopes(new Scope(s)); } GoogleSignInOptions googleSignInOptions = gopBuilder.Build(); var googleApiClientBuilder = new GoogleApiClient.Builder(Application.Context) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions); foreach (var a in _initApis) { googleApiClientBuilder.AddApi(a); } GoogleApiClient = googleApiClientBuilder.Build(); }
/// <summary> /// Creates account manager and attempts to sign in silently (triggers <see cref="OnSuccess"/> or <see cref="OnFailure"/> /// </summary> public static void Create(AppCompatActivity activity) { // Ignore if it has already been created if (googleClient != null) return; // Setup connection listener var connectionListener = new GoogleConnectionListener(); // Setup sign in options signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultGamesSignIn) .RequestScopes(DriveClass.ScopeAppfolder) .Build(); // Create google client googleClient = new GoogleApiClient.Builder(activity) .AddConnectionCallbacks(connectionListener) .AddApi(Auth.GOOGLE_SIGN_IN_API, signInOptions) .AddApi(GamesClass.API) .Build(); googleClient.Connect(GoogleApiClient.SignInModeOptional); // Wait until we connected and attempt to sign in silently when we do connectionListener.Connected += async hint => { var silentSignIn = await Auth.GoogleSignInApi.SilentSignIn(googleClient); if (silentSignIn.Status.IsSuccess) OnSuccess?.Invoke(silentSignIn.Status); else OnFailure?.Invoke(silentSignIn.Status); snapshotManager = new SnapshotManager(googleClient); }; // Register callback to our connection listener googleClient.RegisterConnectionCallbacks(connectionListener); }
public void Initialize(Activity activity, string serverClientId, bool requestProfile, bool requestEmail) { var builder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn); if (requestProfile) { builder = builder.RequestProfile(); } if (requestEmail) { builder = builder.RequestEmail(); } if (!string.IsNullOrEmpty(serverClientId)) { builder = builder.RequestServerAuthCode(serverClientId); } googleSignInOptions = builder.Build(); googleSignInClient = GoogleSignIn.GetClient(activity, googleSignInOptions); Activity = activity; }
internal GoogleClientManager() { var gopBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail(); if (!string.IsNullOrWhiteSpace(_serverClientId)) { gopBuilder.RequestServerAuthCode(_serverClientId, false); } if (!string.IsNullOrWhiteSpace(_clientId)) { gopBuilder.RequestIdToken(_clientId); } GoogleSignInOptions googleSignInOptions = gopBuilder.Build(); GoogleApiClient = new GoogleApiClient.Builder(Application.Context) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions) .AddScope(new Scope(Scopes.Profile)) .Build(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ItemsFragment itemsFragment; itemsFragment = ((StockAppApplicaiton)this.Application).ItemsFragment; onSignIn = itemsFragment; SetContentView(Resource.Layout.SignIn); // Create Layout if (savedInstanceState != null) { mIsResolving = savedInstanceState.GetBoolean(KEY_IS_RESOLVING); mShouldResolve = savedInstanceState.GetBoolean(KEY_SHOULD_RESOLVE); } signInButton = FindViewById(Resource.Id.sign_in_button) as SignInButton; mStatusText = FindViewById(Resource.Id.status) as TextView; signOutButton = FindViewById(Resource.Id.sign_out_button) as Button; disconnectButton = FindViewById(Resource.Id.disconnect_button) as Button; signOutButton.Click += async delegate { var result = await Auth.GoogleSignInApi.SignOut(mGoogleApiClient); UpdateUI(false); ((StockAppApplicaiton)this.Application).acct = null; ((StockAppApplicaiton)this.Application).SignedIn = false; onSignIn.update(); }; disconnectButton.Click += async delegate { var result = await Auth.GoogleSignInApi.RevokeAccess(mGoogleApiClient); UpdateUI(false); ((StockAppApplicaiton)this.Application).acct = null; ((StockAppApplicaiton)this.Application).SignedIn = false; onSignIn.update(); }; signInButton.Click += delegate { Console.WriteLine("I have been Clicked"); Intent signInIntent = Auth.GoogleSignInApi.GetSignInIntent(mGoogleApiClient); Console.WriteLine("I have Created the Intent"); StartActivityForResult(signInIntent, RC_SIGN_IN); Console.WriteLine("I have started the Activity"); }; signInButton.SetSize(SignInButton.SizeWide); signInButton.Enabled = false; gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("50844503444-ufvgj1l9i07r57agtfegnt5tivsvu5b9.apps.googleusercontent.com") .RequestEmail() .Build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .EnableAutoManage(this, this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .AddScope(new Scope(Scopes.Profile)) .Build(); }
void ConnectViews() { Fnametext = (TextInputLayout)FindViewById(Resource.Id.fullnametext); emtext = (TextInputLayout)FindViewById(Resource.Id.emailtext); passtext = (TextInputLayout)FindViewById(Resource.Id.passwordtext); submit = (Button)FindViewById(Resource.Id.submit_btn); login = (Button)FindViewById(Resource.Id.login_btn); googlelogin = (Button)FindViewById(Resource.Id.googlelogin_btn); profimg = (ImageView)FindViewById(Resource.Id.profileiv); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("228992356302-n0p15tka3tqvhps5e7ra7scrs6fqg0p0.apps.googleusercontent.com") .RequestEmail().Build(); googleapiclient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleapiclient.Connect(); submit.Click += (sender, e) => { if (imageArray == null) { imageArray = System.IO.File.ReadAllBytes("Resources/Images/DefaultUser.png"); } storageReference = FirebaseStorage.Instance.GetReference($"users/{Fnametext.EditText.Text}_image"); storageReference.PutBytes(imageArray); storageReference.GetDownloadUrl().AddOnSuccessListener(this); HashMap map = new HashMap(); map.Put("fullname", Fnametext.EditText.Text); map.Put("email", emtext.EditText.Text); map.Put("password", passtext.EditText.Text); map.Put("profileimage", url); DocumentReference docRef = database.Collection("users").Document(); docRef.Set(map); Toast.MakeText(this, "User Registered", ToastLength.Long).Show(); FetchUserData(); }; login.Click += (sender, e) => { string loginfname = Fnametext.EditText.Text.ToString(); string loginemail = emtext.EditText.Text.ToString(); string loginpass = passtext.EditText.Text.ToString(); //listOfUser=userservice.FetchUserData("user"); //while (listOfUser.Count == 0) //{ //} foreach (var item in listOfUser) { Console.WriteLine("Fullname: " + item.Fullname); } foreach (var item in listOfUser) { if (item.Fullname.Equals(loginfname) && item.Email.Equals(loginemail) && item.password.Equals(loginpass)) { Intent secondpageintent = new Intent(this, typeof(SecondPageActivity)); secondpageintent.PutExtra("accepteduser", JsonConvert.SerializeObject(item)); StartActivity(secondpageintent); return; } } Toast.MakeText(this, "Invalid Credentials", ToastLength.Long).Show(); return; }; profimg.Click += (sender, e) => { RequestPermissions(permissionGroup, 0); var trans = SupportFragmentManager.BeginTransaction(); uploadimg = new UploadImageFragment(); uploadimg.Show(trans, "profilepicmethod"); uploadimg.uploadImage += (Bitmap bitmap, byte[] imgary) => { profimg.SetImageBitmap(bitmap); imageArray = imgary; uploadimg.Dismiss(); }; }; googlelogin.Click += (sender, e) => { var intent = Auth.GoogleSignInApi.GetSignInIntent(googleapiclient); StartActivityForResult(intent, 1); }; }