Edw*_*hak 20 ios swift google-signin
我遇到这种情况,GIDSignIn.sharedInstance().signInSilently()返回错误:
错误域= com.google.GIDSignIn代码= -4"无法完成操作.(com.google.GIDSignIn错误-4.)"
我似乎无法在google signin docs或stackOverflow下找到任何关于此错误的文档.
如果我为之前没有签名的用户请求静默signIn,我希望这会发生错误.但令我惊讶的是,当我有一个用户以前签名并且我尝试在几秒钟后第二次静默登录时,它甚至会发生.
我遇到困难的第二个问题是确定是否有用户登录使用:
GIDSignIn.sharedInstance().currentUser
Run Code Online (Sandbox Code Playgroud)
这是一个零或一个GIDGoogleUser对象.
任何帮助在这个问题上取得进展将不胜感激.
谢谢
jha*_*ott 10
以下是错误代码GIDSignIn.h.当密钥链中没有auth令牌时,-4代码将被发送signInSilently.看评论.
// 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,
};
Run Code Online (Sandbox Code Playgroud)
对于谷歌SDK,我发现头文件注释实际上是一个非常好看的地方,通常比任何已发布的文档更具信息性.
小智 9
我遇到了同样的问题.问题出在方法上:
[[GIDSignIn sharedInstance] setScopes:@[@"https://www.googleapis.com/auth/plus.stream.read", @"https://www.googleapis.com/auth/plus.me"]];
Run Code Online (Sandbox Code Playgroud)
你应该先叫它:
[[GIDSignIn sharedInstance] hasAuthInKeychain]
Run Code Online (Sandbox Code Playgroud)
和
[[GIDSignIn sharedInstance] signIn]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7201 次 |
| 最近记录: |