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); }
public GoogleService(Activity activity) { _activity = activity; var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken(activity.GetString(Resource.String.default_web_client_id)) .RequestEmail() .Build(); _client = GoogleSignIn.GetClient(activity, gso); }
// Third partys private void ImgGooglePlay_Click(object sender, EventArgs e) { string serverClientId = Resources.GetString(Resource.String.server_client_id); GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultGamesSignIn) .RequestServerAuthCode(serverClientId) .Build(); GoogleSignInClient googleSignInClient = GoogleSignIn.GetClient(this, googleSignInOptions); Intent signInIntent = googleSignInClient.SignInIntent; StartActivityForResult(signInIntent, 9003); }
public void Connect() { _signInClient = BuildSignInClient(); if (_fromActivity) { _activity.StartActivityForResult(_signInClient.SignInIntent, RequestCodeGoogleSignIn); } else { _fragment.StartActivityForResult(_signInClient.SignInIntent, RequestCodeGoogleSignIn); } }
private GoogleClientManager() { if (currentActivity == null) { throw new GoogleClientNotInitializedErrorException(GoogleClientBaseException.ClientNotInitializedErrorMessage); } var googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken(Constants.GoogleRequestIdToken) .RequestEmail() .RequestScopes(new Scope(Scopes.Profile)) .Build(); googleSignInClient = GoogleSignIn.GetClient(currentActivity, googleSignInOptions); }
private void ImgGoogle_Click(object sender, EventArgs e) { string serverClientId = Resources.GetString(Resource.String.server_client_id); const int RcSignIn = 9001; // Configure sign-in to request the user's ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestProfile() .RequestIdToken(serverClientId) .Build(); GoogleSignInClient googleSignClient = GoogleSignIn.GetClient(this, gso); Intent signInIntent = googleSignClient.SignInIntent; StartActivityForResult(signInIntent, RcSignIn); }
public void Disconnect() { _googleAccountPopupOpened = false; if (_signInClient == null) { _signInClient = BuildSignInClient(); } _signInClient.SignOut(); //_googleApiClient.Disconnect(); //App.State.BackupAccountEmail = string.Empty; //App.Settings.SaveSessionState(); //Disconnected?.Invoke(this, success: true); }
public void Initialize(AuthType type, string clientId = "") { authType = type; switch (authType) { case AuthType.Google: var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken(clientId) .RequestProfile() .RequestEmail() .Build(); signInClient = GoogleSignIn.GetClient(Xamarin.Essentials.Platform.CurrentActivity, gso); break; case AuthType.Facebook: callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(callbackManager, this); break; } }
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; }
private void InitSocialLogins() { try { //#Facebook if (AppSettings.ShowFacebookLogin) { LoginButton loginButton = new LoginButton(this); MprofileTracker = new FbMyProfileTracker(); MprofileTracker.StartTracking(); BtnFacebook = FindViewById <Button>(Resource.Id.btn_facebook); BtnFacebook.Visibility = ViewStates.Visible; BtnFacebook.Click += BtnFacebookOnClick; MprofileTracker.MOnProfileChanged += MprofileTrackerOnMOnProfileChanged; loginButton.SetPermissions(new List <string> { "email", "public_profile" }); MFbCallManager = CallbackManagerFactory.Create(); loginButton.RegisterCallback(MFbCallManager, this); //FB accessToken var accessToken = AccessToken.CurrentAccessToken; var isLoggedIn = accessToken != null && !accessToken.IsExpired; if (isLoggedIn && Profile.CurrentProfile != null) { LoginManager.Instance.LogOut(); } string hashId = Methods.App.GetKeyHashesConfigured(this); Console.WriteLine(hashId); } else { BtnFacebook = FindViewById <Button>(Resource.Id.btn_facebook); BtnFacebook.Visibility = ViewStates.Gone; } //#Google if (AppSettings.ShowGoogleLogin) { // Configure sign-in to request the user's ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN. var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken(AppSettings.ClientId) .RequestScopes(new Scope(Scopes.Profile)) .RequestScopes(new Scope(Scopes.PlusMe)) .RequestScopes(new Scope(Scopes.DriveAppfolder)) .RequestServerAuthCode(AppSettings.ClientId) .RequestProfile().RequestEmail().Build(); MGoogleSignInClient = GoogleSignIn.GetClient(this, gso); BtnGoogle = FindViewById <Button>(Resource.Id.btn_google); BtnGoogle.Click += GoogleSignInButtonOnClick; } else { BtnGoogle = FindViewById <Button>(Resource.Id.btn_google); BtnGoogle.Visibility = ViewStates.Gone; } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public GoogleAuth(Activity activity, string requestToken) { _signInClient = GoogleSignIn.GetClient(activity, CreateGoogleSignInOptions(requestToken)); }