gpt4 book ai didi

objective-c - 谷歌加 iOS SDK : how to get logged in user email?

转载 作者:可可西里 更新时间:2023-11-01 06:19:01 25 4
gpt4 key购买 nike

目前正在使用范围为 GooglePlusSample 的游戏:

@"https://www.googleapis.com/auth/plus.me", 
@"https://www.googleapis.com/auth/userinfo.email" and
@"https://www.googleapis.com/auth/userinfo.profile".

尝试在回调方法finishedWithAuth:error:中调用auth.userEmail、auth.userData,但是都是空的...

最佳答案

-(void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error{

NSLog(@"Received Error %@ and auth object==%@",error,auth);

if (error) {
// Do some error handling here.
} else {
[self refreshInterfaceBasedOnSignIn];

NSLog(@"email %@ ",[NSString stringWithFormat:@"Email: %@",[GPPSignIn sharedInstance].authentication.userEmail]);
NSLog(@"Received error %@ and auth object %@",error, auth);

// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[GTLServicePlus alloc] init] ;
plusService.retryEnabled = YES;

// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];


GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];

// *4. Use the "v1" version of the Google+ API.*
plusService.apiVersion = @"v1";

[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPerson *person,
NSError *error) {
if (error) {



//Handle Error

} else
{


NSLog(@"Email= %@",[GPPSignIn sharedInstance].authentication.userEmail);
NSLog(@"GoogleID=%@",person.identifier);
NSLog(@"User Name=%@",[person.name.givenName stringByAppendingFormat:@" %@",person.name.familyName]);
NSLog(@"Gender=%@",person.gender);

}
}];
}

}

关于objective-c - 谷歌加 iOS SDK : how to get logged in user email?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12076601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com