Google Sign-In Error -4

我的梦境 提交于 2019-12-25 02:46:58

问题


To my knowledge, I have implemented Google Sign-in the exact way that Google states to do it on the website. It was working for a while, but now I cannot get it to work. I am receiving the error "The operation couldn’t be completed. (com.google.GIDSignIn error -4.)" and am unsure on what is happening. I have checked documentation for this specific error and ran through every possible idea on Stack Overflow. I appreciate any help in advance.


回答1:


As mentioned here http://cocoadocs.org/docsets/GoogleSignIn/4.0.0/Constants/GIDSignInErrorCode.html

typedef NS_ENUM(NSInteger, GIDSignInErrorCode ) {
       kGIDSignInErrorCodeUnknown = -1,
       kGIDSignInErrorCodeKeychain = -2,
       kGIDSignInErrorCodeNoSignInHandlersInstalled = -3,
       kGIDSignInErrorCodeHasNoAuthInKeychain = -4,
       kGIDSignInErrorCodeCanceled = -5,
    };

The error means that there are no auth tokens in the keychain, i.e., "User is not authorized". In this case, you signed in, then closed the app and reopened it.

To check if the user is authorized, use this piece of code:

func checkIfUserIsAuthorized() {
    if GIDSignIn.sharedInstance().hasAuthInKeychain() {
        // User authorized before
        GIDSignIn.sharedInstance().signInSilently()
    } else {
        // User not authorized open sign in screen

    }
}


来源:https://stackoverflow.com/questions/37739557/google-sign-in-error-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!