signInSilently() generates an error code=-4How to retrieve age and gender from Google Sign-InSaving the current GIDGoogleUser instead of signing in on every launchAfter logging with FIRAuth.auth()?.signIn(withEmail , GIDSignIn.sharedInstance().hasAuthInKeychain() is nullWhat does this mean? “'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X”How to call Objective-C code from SwiftiOS GCDAsyncSocket Error: Domain=NSPOSIXErrorDomain Code=57Xcode error “Could not find Developer Disk Image”Google+ Sign-In vs Google Sign-In Libraries [iOS 9 canOpenURL error]'user' is always nil in logInInBackgroundWithReadPermissions in Parse iOS SDKiOS 9 read file permissionGoogle SignIn crashes after token is revokedGoogle SignIn not retaining credentials when relaunching App?Google Sign-In for iOS: serverAuthCode is intermittently missing

Has the Hulk always been able to talk?

Where can I go to avoid planes overhead?

Is there an official reason for not adding a post-credits scene?

Adding command shortcuts to bin

Should homeowners insurance cover the cost of the home?

Nominativ or Akkusativ

Pressure inside an infinite ocean?

Find the cheapest shipping option based on item weight

Upside-Down Pyramid Addition...REVERSED!

In Russian, how do you idiomatically express the idea of the figurative "overnight"?

How can I support myself financially as a 17 year old with a loan?

Refinish or replace an old staircase

Why wasn't the Night King naked in S08E03?

Word meaning as function of the composition of its phonemes

Building a list of products from the elements in another list

Why does this derived table improve performance?

Manager is threatening to grade me poorly if I don't complete the project

Do publishers care if submitted work has already been copyrighted?

How to increase the size of the cursor in Lubuntu 19.04?

Copy previous line to current line from text file

How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?

Can a Valor bard Ready a bard spell, then use the Battle Magic feature to make a weapon attack before releasing the spell?

Will 700 more planes a day fly because of the Heathrow expansion?

What was Bran's plan to kill the Night King?



signInSilently() generates an error code=-4


How to retrieve age and gender from Google Sign-InSaving the current GIDGoogleUser instead of signing in on every launchAfter logging with FIRAuth.auth()?.signIn(withEmail , GIDSignIn.sharedInstance().hasAuthInKeychain() is nullWhat does this mean? “'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X”How to call Objective-C code from SwiftiOS GCDAsyncSocket Error: Domain=NSPOSIXErrorDomain Code=57Xcode error “Could not find Developer Disk Image”Google+ Sign-In vs Google Sign-In Libraries [iOS 9 canOpenURL error]'user' is always nil in logInInBackgroundWithReadPermissions in Parse iOS SDKiOS 9 read file permissionGoogle SignIn crashes after token is revokedGoogle SignIn not retaining credentials when relaunching App?Google Sign-In for iOS: serverAuthCode is intermittently missing






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








19















I'm having this case where the GIDSignIn.sharedInstance().signInSilently() is returning an error:




Error Domain=com.google.GIDSignIn Code=-4 "The operation couldn’t be
completed. (com.google.GIDSignIn error -4.)"




I can't seem to find any documentation of this error under the google signin docs or stackOverflow for that matter.



I'm expecting this to error to happen if I request a silent signIn for no previously signedIn user.
But to my surprise it even happens when I have a user previously signedIn and I attempt to signIn Silently a second time after a few seconds.



A second issue I'm having difficulty with is to determine if there is a user signed In using :



GIDSignIn.sharedInstance().currentUser


which is either a nil or a GIDGoogleUser object.



Any help making progress on this issue would be much appreciated.



Thanks










share|improve this question




























    19















    I'm having this case where the GIDSignIn.sharedInstance().signInSilently() is returning an error:




    Error Domain=com.google.GIDSignIn Code=-4 "The operation couldn’t be
    completed. (com.google.GIDSignIn error -4.)"




    I can't seem to find any documentation of this error under the google signin docs or stackOverflow for that matter.



    I'm expecting this to error to happen if I request a silent signIn for no previously signedIn user.
    But to my surprise it even happens when I have a user previously signedIn and I attempt to signIn Silently a second time after a few seconds.



    A second issue I'm having difficulty with is to determine if there is a user signed In using :



    GIDSignIn.sharedInstance().currentUser


    which is either a nil or a GIDGoogleUser object.



    Any help making progress on this issue would be much appreciated.



    Thanks










    share|improve this question
























      19












      19








      19








      I'm having this case where the GIDSignIn.sharedInstance().signInSilently() is returning an error:




      Error Domain=com.google.GIDSignIn Code=-4 "The operation couldn’t be
      completed. (com.google.GIDSignIn error -4.)"




      I can't seem to find any documentation of this error under the google signin docs or stackOverflow for that matter.



      I'm expecting this to error to happen if I request a silent signIn for no previously signedIn user.
      But to my surprise it even happens when I have a user previously signedIn and I attempt to signIn Silently a second time after a few seconds.



      A second issue I'm having difficulty with is to determine if there is a user signed In using :



      GIDSignIn.sharedInstance().currentUser


      which is either a nil or a GIDGoogleUser object.



      Any help making progress on this issue would be much appreciated.



      Thanks










      share|improve this question














      I'm having this case where the GIDSignIn.sharedInstance().signInSilently() is returning an error:




      Error Domain=com.google.GIDSignIn Code=-4 "The operation couldn’t be
      completed. (com.google.GIDSignIn error -4.)"




      I can't seem to find any documentation of this error under the google signin docs or stackOverflow for that matter.



      I'm expecting this to error to happen if I request a silent signIn for no previously signedIn user.
      But to my surprise it even happens when I have a user previously signedIn and I attempt to signIn Silently a second time after a few seconds.



      A second issue I'm having difficulty with is to determine if there is a user signed In using :



      GIDSignIn.sharedInstance().currentUser


      which is either a nil or a GIDGoogleUser object.



      Any help making progress on this issue would be much appreciated.



      Thanks







      ios swift google-signin






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 16 '15 at 17:47









      Edward AshakEdward Ashak

      1,40311434




      1,40311434






















          8 Answers
          8






          active

          oldest

          votes


















          10














          Here are the error codes from GIDSignIn.h. The -4 code is sent by signInSilently when there are no auth tokens in the keychain. See comments.



          // A list of potential error codes returned from the Google Identity SDK.
          typedef NS_ENUM(NSInteger, GIDSignInErrorCode)
          // Indicates an unknown error has occured.
          kGIDSignInErrorCodeUnknown = -1,
          // Indicates a problem reading or writing to the application keychain.
          kGIDSignInErrorCodeKeychain = -2,
          // Indicates no appropriate applications are installed on the user's device which can handle
          // sign-in. This code will only ever be returned if using webview and switching to browser have
          // both been disabled.
          kGIDSignInErrorCodeNoSignInHandlersInstalled = -3,
          // Indicates there are no auth tokens in the keychain. This error code will be returned by
          // signInSilently if the user has never signed in before with the given scopes, or if they have
          // since signed out.
          kGIDSignInErrorCodeHasNoAuthInKeychain = -4,
          // Indicates the user canceled the sign in request.
          kGIDSignInErrorCodeCanceled = -5,
          ;


          For the Google SDKs in general I've found the header file comments are actually a pretty good place to look, usually more informative than any published documentation.






          share|improve this answer

























          • Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

            – Edward Ashak
            Jul 17 '15 at 15:01











          • Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

            – jhabbott
            Jul 18 '15 at 16:41






          • 2





            Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

            – omarojo
            Nov 26 '15 at 2:00


















          8














          I've had the same problem. The problem was in method:



          [[GIDSignIn sharedInstance] setScopes:@[@"https://www.googleapis.com/auth/plus.stream.read", @"https://www.googleapis.com/auth/plus.me"]];


          you should call it before:



          [[GIDSignIn sharedInstance] hasAuthInKeychain] 


          and



          [[GIDSignIn sharedInstance] signIn] 





          share|improve this answer






























            4














            I had the same issue here, but I finally found the answer.
            I found GoogleSignIn taking UserDefault for keeping previous sign-in status. Please check whether or not you use UserDefault to develop your application. If you do, please make sure you won't delete all of the data in your UserDefault if you want to keep previous sign-in status.



            In my case,



            public func resetUserDafault() 

            let userDefaults = UserDefaults.standard

            let dict = UserDefaults.standard.dictionaryRepresentation()

            for key in dict.keys

            //GoogleSignIn take this key to check previous signin status

            if key == "GID_AppHasRunBefore"

            continue



            userDefaults.removeObject(forKey: key);



            UserDefaults.standard.synchronize()



            override func viewDidLoad()

            super.viewDidLoad()

            //After doing it, my application is working properly now.

            if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

            GIDSignIn.sharedInstance().signInSilently()


            else

            //not sign in









            share|improve this answer






























              2














              Igor Rotaru had the correct answer. The key is to have the scopes set before using signInSilently. It will check if the user has ever signed in before with the scopes that you previously set and signed in with.






              share|improve this answer






























                2














                If you are using a custom button then you need to check auth in keychain.



                if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                GIDSignIn.sharedInstance().signInSilently()


                else

                GIDSignIn.sharedInstance().signIn()







                share|improve this answer


















                • 1





                  Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                  – Jonathan Tuzman
                  Aug 27 '18 at 20:01


















                0














                Please refer my answer from Saving the current GIDGoogleUser instead of signing in on every launch



                you should conform the GIDSignInUIDelegate protocol without implementing the methods.



                signInWillDispatch:error: 
                signIn:presentViewController:
                signIn:dismissViewController:


                It will fix your error -4.






                share|improve this answer
































                  0














                  check if internet is available then proceed with your staff.
                  I got this error when iPad was not connected on the secondary signed in checks.






                  share|improve this answer
































                    0














                    Both Igor and Spydy worked for me



                    A swift version of Igor's post



                     GIDSignIn.sharedInstance().uiDelegate = self

                    GIDSignIn.sharedInstance()?.hasAuthInKeychain()
                    GIDSignIn.sharedInstance()?.signIn()

                    // Uncomment to automatically sign in the user.
                    GIDSignIn.sharedInstance().signInSilently()


                    or from Spydy.



                     // google sign in setup
                    GIDSignIn.sharedInstance().uiDelegate = self
                    if GIDSignIn.sharedInstance().hasAuthInKeychain() == true
                    GIDSignIn.sharedInstance().signInSilently()

                    else
                    GIDSignIn.sharedInstance().signIn()






                    share|improve this answer























                      Your Answer






                      StackExchange.ifUsing("editor", function ()
                      StackExchange.using("externalEditor", function ()
                      StackExchange.using("snippets", function ()
                      StackExchange.snippets.init();
                      );
                      );
                      , "code-snippets");

                      StackExchange.ready(function()
                      var channelOptions =
                      tags: "".split(" "),
                      id: "1"
                      ;
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function()
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled)
                      StackExchange.using("snippets", function()
                      createEditor();
                      );

                      else
                      createEditor();

                      );

                      function createEditor()
                      StackExchange.prepareEditor(
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: true,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: 10,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader:
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      ,
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      );



                      );













                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31461139%2fsigninsilently-generates-an-error-code-4%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown

























                      8 Answers
                      8






                      active

                      oldest

                      votes








                      8 Answers
                      8






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      10














                      Here are the error codes from GIDSignIn.h. The -4 code is sent by signInSilently when there are no auth tokens in the keychain. See comments.



                      // A list of potential error codes returned from the Google Identity SDK.
                      typedef NS_ENUM(NSInteger, GIDSignInErrorCode)
                      // Indicates an unknown error has occured.
                      kGIDSignInErrorCodeUnknown = -1,
                      // Indicates a problem reading or writing to the application keychain.
                      kGIDSignInErrorCodeKeychain = -2,
                      // Indicates no appropriate applications are installed on the user's device which can handle
                      // sign-in. This code will only ever be returned if using webview and switching to browser have
                      // both been disabled.
                      kGIDSignInErrorCodeNoSignInHandlersInstalled = -3,
                      // Indicates there are no auth tokens in the keychain. This error code will be returned by
                      // signInSilently if the user has never signed in before with the given scopes, or if they have
                      // since signed out.
                      kGIDSignInErrorCodeHasNoAuthInKeychain = -4,
                      // Indicates the user canceled the sign in request.
                      kGIDSignInErrorCodeCanceled = -5,
                      ;


                      For the Google SDKs in general I've found the header file comments are actually a pretty good place to look, usually more informative than any published documentation.






                      share|improve this answer

























                      • Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

                        – Edward Ashak
                        Jul 17 '15 at 15:01











                      • Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

                        – jhabbott
                        Jul 18 '15 at 16:41






                      • 2





                        Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

                        – omarojo
                        Nov 26 '15 at 2:00















                      10














                      Here are the error codes from GIDSignIn.h. The -4 code is sent by signInSilently when there are no auth tokens in the keychain. See comments.



                      // A list of potential error codes returned from the Google Identity SDK.
                      typedef NS_ENUM(NSInteger, GIDSignInErrorCode)
                      // Indicates an unknown error has occured.
                      kGIDSignInErrorCodeUnknown = -1,
                      // Indicates a problem reading or writing to the application keychain.
                      kGIDSignInErrorCodeKeychain = -2,
                      // Indicates no appropriate applications are installed on the user's device which can handle
                      // sign-in. This code will only ever be returned if using webview and switching to browser have
                      // both been disabled.
                      kGIDSignInErrorCodeNoSignInHandlersInstalled = -3,
                      // Indicates there are no auth tokens in the keychain. This error code will be returned by
                      // signInSilently if the user has never signed in before with the given scopes, or if they have
                      // since signed out.
                      kGIDSignInErrorCodeHasNoAuthInKeychain = -4,
                      // Indicates the user canceled the sign in request.
                      kGIDSignInErrorCodeCanceled = -5,
                      ;


                      For the Google SDKs in general I've found the header file comments are actually a pretty good place to look, usually more informative than any published documentation.






                      share|improve this answer

























                      • Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

                        – Edward Ashak
                        Jul 17 '15 at 15:01











                      • Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

                        – jhabbott
                        Jul 18 '15 at 16:41






                      • 2





                        Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

                        – omarojo
                        Nov 26 '15 at 2:00













                      10












                      10








                      10







                      Here are the error codes from GIDSignIn.h. The -4 code is sent by signInSilently when there are no auth tokens in the keychain. See comments.



                      // A list of potential error codes returned from the Google Identity SDK.
                      typedef NS_ENUM(NSInteger, GIDSignInErrorCode)
                      // Indicates an unknown error has occured.
                      kGIDSignInErrorCodeUnknown = -1,
                      // Indicates a problem reading or writing to the application keychain.
                      kGIDSignInErrorCodeKeychain = -2,
                      // Indicates no appropriate applications are installed on the user's device which can handle
                      // sign-in. This code will only ever be returned if using webview and switching to browser have
                      // both been disabled.
                      kGIDSignInErrorCodeNoSignInHandlersInstalled = -3,
                      // Indicates there are no auth tokens in the keychain. This error code will be returned by
                      // signInSilently if the user has never signed in before with the given scopes, or if they have
                      // since signed out.
                      kGIDSignInErrorCodeHasNoAuthInKeychain = -4,
                      // Indicates the user canceled the sign in request.
                      kGIDSignInErrorCodeCanceled = -5,
                      ;


                      For the Google SDKs in general I've found the header file comments are actually a pretty good place to look, usually more informative than any published documentation.






                      share|improve this answer















                      Here are the error codes from GIDSignIn.h. The -4 code is sent by signInSilently when there are no auth tokens in the keychain. See comments.



                      // A list of potential error codes returned from the Google Identity SDK.
                      typedef NS_ENUM(NSInteger, GIDSignInErrorCode)
                      // Indicates an unknown error has occured.
                      kGIDSignInErrorCodeUnknown = -1,
                      // Indicates a problem reading or writing to the application keychain.
                      kGIDSignInErrorCodeKeychain = -2,
                      // Indicates no appropriate applications are installed on the user's device which can handle
                      // sign-in. This code will only ever be returned if using webview and switching to browser have
                      // both been disabled.
                      kGIDSignInErrorCodeNoSignInHandlersInstalled = -3,
                      // Indicates there are no auth tokens in the keychain. This error code will be returned by
                      // signInSilently if the user has never signed in before with the given scopes, or if they have
                      // since signed out.
                      kGIDSignInErrorCodeHasNoAuthInKeychain = -4,
                      // Indicates the user canceled the sign in request.
                      kGIDSignInErrorCodeCanceled = -5,
                      ;


                      For the Google SDKs in general I've found the header file comments are actually a pretty good place to look, usually more informative than any published documentation.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jul 17 '15 at 15:32

























                      answered Jul 17 '15 at 14:58









                      jhabbottjhabbott

                      11.4k85083




                      11.4k85083












                      • Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

                        – Edward Ashak
                        Jul 17 '15 at 15:01











                      • Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

                        – jhabbott
                        Jul 18 '15 at 16:41






                      • 2





                        Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

                        – omarojo
                        Nov 26 '15 at 2:00

















                      • Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

                        – Edward Ashak
                        Jul 17 '15 at 15:01











                      • Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

                        – jhabbott
                        Jul 18 '15 at 16:41






                      • 2





                        Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

                        – omarojo
                        Nov 26 '15 at 2:00
















                      Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

                      – Edward Ashak
                      Jul 17 '15 at 15:01





                      Thanks for the snippet @jhabbott, any idea why the keychain item would not be found if the user signed in a few seconds ago ?

                      – Edward Ashak
                      Jul 17 '15 at 15:01













                      Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

                      – jhabbott
                      Jul 18 '15 at 16:41





                      Nope - it should be ok if you used signIn the first time and it worked. Wish I knew any more!

                      – jhabbott
                      Jul 18 '15 at 16:41




                      2




                      2





                      Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

                      – omarojo
                      Nov 26 '15 at 2:00





                      Im having the exact same problem. I signIn and everything goes well. I can do silent signing again, and is okay. But if I kill the app and open it again, silent signIn fails with error -4. Like if its not saving anything in the Keychain any luck with this @jhabbott ?

                      – omarojo
                      Nov 26 '15 at 2:00













                      8














                      I've had the same problem. The problem was in method:



                      [[GIDSignIn sharedInstance] setScopes:@[@"https://www.googleapis.com/auth/plus.stream.read", @"https://www.googleapis.com/auth/plus.me"]];


                      you should call it before:



                      [[GIDSignIn sharedInstance] hasAuthInKeychain] 


                      and



                      [[GIDSignIn sharedInstance] signIn] 





                      share|improve this answer



























                        8














                        I've had the same problem. The problem was in method:



                        [[GIDSignIn sharedInstance] setScopes:@[@"https://www.googleapis.com/auth/plus.stream.read", @"https://www.googleapis.com/auth/plus.me"]];


                        you should call it before:



                        [[GIDSignIn sharedInstance] hasAuthInKeychain] 


                        and



                        [[GIDSignIn sharedInstance] signIn] 





                        share|improve this answer

























                          8












                          8








                          8







                          I've had the same problem. The problem was in method:



                          [[GIDSignIn sharedInstance] setScopes:@[@"https://www.googleapis.com/auth/plus.stream.read", @"https://www.googleapis.com/auth/plus.me"]];


                          you should call it before:



                          [[GIDSignIn sharedInstance] hasAuthInKeychain] 


                          and



                          [[GIDSignIn sharedInstance] signIn] 





                          share|improve this answer













                          I've had the same problem. The problem was in method:



                          [[GIDSignIn sharedInstance] setScopes:@[@"https://www.googleapis.com/auth/plus.stream.read", @"https://www.googleapis.com/auth/plus.me"]];


                          you should call it before:



                          [[GIDSignIn sharedInstance] hasAuthInKeychain] 


                          and



                          [[GIDSignIn sharedInstance] signIn] 






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 3 '16 at 19:31









                          Igor RotaruIgor Rotaru

                          15427




                          15427





















                              4














                              I had the same issue here, but I finally found the answer.
                              I found GoogleSignIn taking UserDefault for keeping previous sign-in status. Please check whether or not you use UserDefault to develop your application. If you do, please make sure you won't delete all of the data in your UserDefault if you want to keep previous sign-in status.



                              In my case,



                              public func resetUserDafault() 

                              let userDefaults = UserDefaults.standard

                              let dict = UserDefaults.standard.dictionaryRepresentation()

                              for key in dict.keys

                              //GoogleSignIn take this key to check previous signin status

                              if key == "GID_AppHasRunBefore"

                              continue



                              userDefaults.removeObject(forKey: key);



                              UserDefaults.standard.synchronize()



                              override func viewDidLoad()

                              super.viewDidLoad()

                              //After doing it, my application is working properly now.

                              if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                              GIDSignIn.sharedInstance().signInSilently()


                              else

                              //not sign in









                              share|improve this answer



























                                4














                                I had the same issue here, but I finally found the answer.
                                I found GoogleSignIn taking UserDefault for keeping previous sign-in status. Please check whether or not you use UserDefault to develop your application. If you do, please make sure you won't delete all of the data in your UserDefault if you want to keep previous sign-in status.



                                In my case,



                                public func resetUserDafault() 

                                let userDefaults = UserDefaults.standard

                                let dict = UserDefaults.standard.dictionaryRepresentation()

                                for key in dict.keys

                                //GoogleSignIn take this key to check previous signin status

                                if key == "GID_AppHasRunBefore"

                                continue



                                userDefaults.removeObject(forKey: key);



                                UserDefaults.standard.synchronize()



                                override func viewDidLoad()

                                super.viewDidLoad()

                                //After doing it, my application is working properly now.

                                if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                GIDSignIn.sharedInstance().signInSilently()


                                else

                                //not sign in









                                share|improve this answer

























                                  4












                                  4








                                  4







                                  I had the same issue here, but I finally found the answer.
                                  I found GoogleSignIn taking UserDefault for keeping previous sign-in status. Please check whether or not you use UserDefault to develop your application. If you do, please make sure you won't delete all of the data in your UserDefault if you want to keep previous sign-in status.



                                  In my case,



                                  public func resetUserDafault() 

                                  let userDefaults = UserDefaults.standard

                                  let dict = UserDefaults.standard.dictionaryRepresentation()

                                  for key in dict.keys

                                  //GoogleSignIn take this key to check previous signin status

                                  if key == "GID_AppHasRunBefore"

                                  continue



                                  userDefaults.removeObject(forKey: key);



                                  UserDefaults.standard.synchronize()



                                  override func viewDidLoad()

                                  super.viewDidLoad()

                                  //After doing it, my application is working properly now.

                                  if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                  GIDSignIn.sharedInstance().signInSilently()


                                  else

                                  //not sign in









                                  share|improve this answer













                                  I had the same issue here, but I finally found the answer.
                                  I found GoogleSignIn taking UserDefault for keeping previous sign-in status. Please check whether or not you use UserDefault to develop your application. If you do, please make sure you won't delete all of the data in your UserDefault if you want to keep previous sign-in status.



                                  In my case,



                                  public func resetUserDafault() 

                                  let userDefaults = UserDefaults.standard

                                  let dict = UserDefaults.standard.dictionaryRepresentation()

                                  for key in dict.keys

                                  //GoogleSignIn take this key to check previous signin status

                                  if key == "GID_AppHasRunBefore"

                                  continue



                                  userDefaults.removeObject(forKey: key);



                                  UserDefaults.standard.synchronize()



                                  override func viewDidLoad()

                                  super.viewDidLoad()

                                  //After doing it, my application is working properly now.

                                  if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                  GIDSignIn.sharedInstance().signInSilently()


                                  else

                                  //not sign in










                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Apr 11 '17 at 7:02









                                  Shih KenShih Ken

                                  427310




                                  427310





















                                      2














                                      Igor Rotaru had the correct answer. The key is to have the scopes set before using signInSilently. It will check if the user has ever signed in before with the scopes that you previously set and signed in with.






                                      share|improve this answer



























                                        2














                                        Igor Rotaru had the correct answer. The key is to have the scopes set before using signInSilently. It will check if the user has ever signed in before with the scopes that you previously set and signed in with.






                                        share|improve this answer

























                                          2












                                          2








                                          2







                                          Igor Rotaru had the correct answer. The key is to have the scopes set before using signInSilently. It will check if the user has ever signed in before with the scopes that you previously set and signed in with.






                                          share|improve this answer













                                          Igor Rotaru had the correct answer. The key is to have the scopes set before using signInSilently. It will check if the user has ever signed in before with the scopes that you previously set and signed in with.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Sep 14 '16 at 16:11









                                          chourobinchourobin

                                          2,78942748




                                          2,78942748





















                                              2














                                              If you are using a custom button then you need to check auth in keychain.



                                              if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                              GIDSignIn.sharedInstance().signInSilently()


                                              else

                                              GIDSignIn.sharedInstance().signIn()







                                              share|improve this answer


















                                              • 1





                                                Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                                                – Jonathan Tuzman
                                                Aug 27 '18 at 20:01















                                              2














                                              If you are using a custom button then you need to check auth in keychain.



                                              if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                              GIDSignIn.sharedInstance().signInSilently()


                                              else

                                              GIDSignIn.sharedInstance().signIn()







                                              share|improve this answer


















                                              • 1





                                                Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                                                – Jonathan Tuzman
                                                Aug 27 '18 at 20:01













                                              2












                                              2








                                              2







                                              If you are using a custom button then you need to check auth in keychain.



                                              if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                              GIDSignIn.sharedInstance().signInSilently()


                                              else

                                              GIDSignIn.sharedInstance().signIn()







                                              share|improve this answer













                                              If you are using a custom button then you need to check auth in keychain.



                                              if GIDSignIn.sharedInstance().hasAuthInKeychain() == true

                                              GIDSignIn.sharedInstance().signInSilently()


                                              else

                                              GIDSignIn.sharedInstance().signIn()








                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Feb 12 '18 at 7:04









                                              SpydySpydy

                                              1,0531111




                                              1,0531111







                                              • 1





                                                Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                                                – Jonathan Tuzman
                                                Aug 27 '18 at 20:01












                                              • 1





                                                Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                                                – Jonathan Tuzman
                                                Aug 27 '18 at 20:01







                                              1




                                              1





                                              Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                                              – Jonathan Tuzman
                                              Aug 27 '18 at 20:01





                                              Not sure no one else has upvoted this, but this absolutely fixed it for me!!

                                              – Jonathan Tuzman
                                              Aug 27 '18 at 20:01











                                              0














                                              Please refer my answer from Saving the current GIDGoogleUser instead of signing in on every launch



                                              you should conform the GIDSignInUIDelegate protocol without implementing the methods.



                                              signInWillDispatch:error: 
                                              signIn:presentViewController:
                                              signIn:dismissViewController:


                                              It will fix your error -4.






                                              share|improve this answer





























                                                0














                                                Please refer my answer from Saving the current GIDGoogleUser instead of signing in on every launch



                                                you should conform the GIDSignInUIDelegate protocol without implementing the methods.



                                                signInWillDispatch:error: 
                                                signIn:presentViewController:
                                                signIn:dismissViewController:


                                                It will fix your error -4.






                                                share|improve this answer



























                                                  0












                                                  0








                                                  0







                                                  Please refer my answer from Saving the current GIDGoogleUser instead of signing in on every launch



                                                  you should conform the GIDSignInUIDelegate protocol without implementing the methods.



                                                  signInWillDispatch:error: 
                                                  signIn:presentViewController:
                                                  signIn:dismissViewController:


                                                  It will fix your error -4.






                                                  share|improve this answer















                                                  Please refer my answer from Saving the current GIDGoogleUser instead of signing in on every launch



                                                  you should conform the GIDSignInUIDelegate protocol without implementing the methods.



                                                  signInWillDispatch:error: 
                                                  signIn:presentViewController:
                                                  signIn:dismissViewController:


                                                  It will fix your error -4.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited May 23 '17 at 12:17









                                                  Community

                                                  11




                                                  11










                                                  answered Jan 7 '16 at 10:45









                                                  AvisSivaAvisSiva

                                                  140311




                                                  140311





















                                                      0














                                                      check if internet is available then proceed with your staff.
                                                      I got this error when iPad was not connected on the secondary signed in checks.






                                                      share|improve this answer





























                                                        0














                                                        check if internet is available then proceed with your staff.
                                                        I got this error when iPad was not connected on the secondary signed in checks.






                                                        share|improve this answer



























                                                          0












                                                          0








                                                          0







                                                          check if internet is available then proceed with your staff.
                                                          I got this error when iPad was not connected on the secondary signed in checks.






                                                          share|improve this answer















                                                          check if internet is available then proceed with your staff.
                                                          I got this error when iPad was not connected on the secondary signed in checks.







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited May 8 '18 at 16:32

























                                                          answered May 8 '18 at 15:36









                                                          Boris GafurovBoris Gafurov

                                                          1,0071026




                                                          1,0071026





















                                                              0














                                                              Both Igor and Spydy worked for me



                                                              A swift version of Igor's post



                                                               GIDSignIn.sharedInstance().uiDelegate = self

                                                              GIDSignIn.sharedInstance()?.hasAuthInKeychain()
                                                              GIDSignIn.sharedInstance()?.signIn()

                                                              // Uncomment to automatically sign in the user.
                                                              GIDSignIn.sharedInstance().signInSilently()


                                                              or from Spydy.



                                                               // google sign in setup
                                                              GIDSignIn.sharedInstance().uiDelegate = self
                                                              if GIDSignIn.sharedInstance().hasAuthInKeychain() == true
                                                              GIDSignIn.sharedInstance().signInSilently()

                                                              else
                                                              GIDSignIn.sharedInstance().signIn()






                                                              share|improve this answer



























                                                                0














                                                                Both Igor and Spydy worked for me



                                                                A swift version of Igor's post



                                                                 GIDSignIn.sharedInstance().uiDelegate = self

                                                                GIDSignIn.sharedInstance()?.hasAuthInKeychain()
                                                                GIDSignIn.sharedInstance()?.signIn()

                                                                // Uncomment to automatically sign in the user.
                                                                GIDSignIn.sharedInstance().signInSilently()


                                                                or from Spydy.



                                                                 // google sign in setup
                                                                GIDSignIn.sharedInstance().uiDelegate = self
                                                                if GIDSignIn.sharedInstance().hasAuthInKeychain() == true
                                                                GIDSignIn.sharedInstance().signInSilently()

                                                                else
                                                                GIDSignIn.sharedInstance().signIn()






                                                                share|improve this answer

























                                                                  0












                                                                  0








                                                                  0







                                                                  Both Igor and Spydy worked for me



                                                                  A swift version of Igor's post



                                                                   GIDSignIn.sharedInstance().uiDelegate = self

                                                                  GIDSignIn.sharedInstance()?.hasAuthInKeychain()
                                                                  GIDSignIn.sharedInstance()?.signIn()

                                                                  // Uncomment to automatically sign in the user.
                                                                  GIDSignIn.sharedInstance().signInSilently()


                                                                  or from Spydy.



                                                                   // google sign in setup
                                                                  GIDSignIn.sharedInstance().uiDelegate = self
                                                                  if GIDSignIn.sharedInstance().hasAuthInKeychain() == true
                                                                  GIDSignIn.sharedInstance().signInSilently()

                                                                  else
                                                                  GIDSignIn.sharedInstance().signIn()






                                                                  share|improve this answer













                                                                  Both Igor and Spydy worked for me



                                                                  A swift version of Igor's post



                                                                   GIDSignIn.sharedInstance().uiDelegate = self

                                                                  GIDSignIn.sharedInstance()?.hasAuthInKeychain()
                                                                  GIDSignIn.sharedInstance()?.signIn()

                                                                  // Uncomment to automatically sign in the user.
                                                                  GIDSignIn.sharedInstance().signInSilently()


                                                                  or from Spydy.



                                                                   // google sign in setup
                                                                  GIDSignIn.sharedInstance().uiDelegate = self
                                                                  if GIDSignIn.sharedInstance().hasAuthInKeychain() == true
                                                                  GIDSignIn.sharedInstance().signInSilently()

                                                                  else
                                                                  GIDSignIn.sharedInstance().signIn()







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered Mar 23 at 0:07









                                                                  Eric StevensonEric Stevenson

                                                                  363




                                                                  363



























                                                                      draft saved

                                                                      draft discarded
















































                                                                      Thanks for contributing an answer to Stack Overflow!


                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                      But avoid


                                                                      • Asking for help, clarification, or responding to other answers.

                                                                      • Making statements based on opinion; back them up with references or personal experience.

                                                                      To learn more, see our tips on writing great answers.




                                                                      draft saved


                                                                      draft discarded














                                                                      StackExchange.ready(
                                                                      function ()
                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31461139%2fsigninsilently-generates-an-error-code-4%23new-answer', 'question_page');

                                                                      );

                                                                      Post as a guest















                                                                      Required, but never shown





















































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown

































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown







                                                                      Popular posts from this blog

                                                                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                                                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                                                                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript