Fog*_*ter 4 objective-c ios google-plus
我正在尝试将GooglePlus API添加到我的应用中.
我已经使用CocoaPods添加了Google+框架,我的应用程序中已经有了登录按钮.
该GPPSignIn对象viewDidLoad在视图控制器中执行登录的函数中设置如下...
@property (nonatomic, strong) GPPSignIn *signIn;
...
self.signIn = [GPPSignIn sharedInstance];
self.signIn.clientID = @"blahblahmynumber.apps.googleusercontent.com";
self.signIn.scopes = @[kGTLAuthScopePlusLogin];
self.signIn.delegate = self;
[self.signIn trySilentAuthentication];
Run Code Online (Sandbox Code Playgroud)
然后按下登录按钮时......
- (IBAction)googleButtonPressed:(id)sender
{
[self.signIn authenticate];
}
Run Code Online (Sandbox Code Playgroud)
......和委托方法......
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error
{
NSLog(@"Received error %@ and auth object %@",error, auth);
}
Run Code Online (Sandbox Code Playgroud)
这一切似乎都有效,我被推到谷歌登录并确认访问我的帐户,然后我被推回到应用程序,控制台显示...
收到错误错误域= com.google.GooglePlusPlatform代码= -1"不匹配的身份验证"UserInfo = 0x1d5cb170 {NSLocalizedDescription =不匹配的身份验证}和身份验证对象(null)
现在我被卡住了.我找不到任何有关"不匹配的身份验证"的含义的信息?
顺便说一句,我编写的所有代码都来自Google开发人员门户网站和"如何"文档.
到目前为止我尝试过的事情
kGTLAuthScopePlusLogin和将范围数组更改为所有可能的组合kGTLAuthScopePlusMe.redirect_uri_mismatch问题.登录后问题是"不匹配的身份验证"返回到登录代理.Fog*_*ter 15
好的,修复这个很容易.删除一些代码.
我按照Google文档关于如何在屏幕上创建登录信.
我添加并将其GPPSignInButton附加到要运行的函数[signIn authenticate].
但是,这是我出错的地方.在GPPSignInButton具有该功能内置的.不知何故,通过使其恰好运行相同的功能这是造成出现此错误.
修复很简单.只需删除按钮上的操作即可.该按钮看起来没有任何功能,但实际上它可以作为登录按钮正常工作.
在文档中,它说用于[self.signIn authenticate];启动登录过程.它并没有说,如果你使用GPPSignInButton它自动完成它.Grr :(无论如何,我现在通过删除代码登录来修复它...
希望这有助于某人.
| 归档时间: |
|
| 查看次数: |
2427 次 |
| 最近记录: |