Nis*_*shi 14 iphone google-login access-token ios google-plus
场景:通过Google+登录登录应用
执行:
- (void)viewDidLoad {
[super viewDidLoad];
GPPSignIn *aGPSSignIn = [GPPSignIn sharedInstance];
aGPSSignIn.scopes = @[ kGTLAuthScopePlusLogin, kGTLAuthScopePlusUserinfoEmail, kGTLAuthScopePlusUserinfoProfile, kGTLAuthScopePlusMe];
aGPSSignIn.shouldFetchGoogleUserEmail = YES;
aGPSSignIn.shouldFetchGooglePlusUser =YES;
aGPSSignIn.homeServerClientID = kClientID;
aGPSSignIn.clientID = kClientID;
aGPSSignIn.delegate = self;
if (![aGPSSignIn trySilentAuthentication]) {
[self showLoginButton];
}
}
- (void)showLoginButton {
if (!self.signInButton) {
self.signInButton = [GPPSignInButton buttonWithType:UIButtonTypeCustom];
[self.signInButton setFrame:CGRectMake(60, 100, 200, 40)];
}
[self.view addSubview:self.signInButton];
}
#pragma mark - GPPSignInDelegate
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error {
NSString *anAccessToken = auth.accessToken;
NSLog(@"googleAccessToken:%@",anAccessToken);
}
- (void)didDisconnectWithError:(NSError *)iError {
if (iError) {
NSLog(@"Error:%@", iError);
}
}
Run Code Online (Sandbox Code Playgroud)
注意:- (BOOL)application: (UIApplication *)application openURL: (NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation: (id)annotation在AppDelegate中处理.
问题:
错误:
收到错误错误域= com.google.GooglePlusPlatform代码= -1"无法完成操作.(com.google.HTTPStatus错误400.)"UserInfo = 0x15d95f90 {NSLocalizedDescription =操作无法完成.(com.google.HTTPStatus错误400.)}和auth对象(null)
如果有人可以指导我解决这个问题,将会非常有帮助.谢谢.
| 归档时间: |
|
| 查看次数: |
1139 次 |
| 最近记录: |