Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
704 views
in Technique[技术] by (71.8m points)

ios - signInSilently() generates an error code=-4

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...