gpt4 book ai didi

iphone - 我已经在我的 IOS 应用程序中集成了 google plus,但是我无法获取当前登录用户的电子邮件 ID

转载 作者:行者123 更新时间:2023-12-01 17:17:33 24 4
gpt4 key购买 nike

我已经在我的 ios 应用程序中集成了 google plus,我能够成功登录,但我无法获取当前登录用户的电子邮件 ID。
我引用了https://developers.google.com/+/mobile/ios/并已完成登录所需的所有步骤!

那么,我如何获得在 Google plus 中登录的当前用户邮件 ID?

enter image description here

最佳答案

转到 GTMOAuth2Authentication.m 文件
dic 中的 setKeysForResponseDictionary 方法返回访问 token
在方法结束时。

accessTocken = [dict valueForKey:@"access_token"]; // access tocken pass in .pch file
[accessTocken retain];

在你的 Controller 中
- (IBAction)momentButton:(id)sender {
NSString *str = [NSString stringWithFormat:@"https://www.googleapis.com/oauth2/v1/userinfo?access_token=%@",accessTocken];
NSString* escapedUrl = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",escapedUrl]];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:url usedEncoding:nil error:nil];
NSMutableDictionary *proDic = [[NSMutableDictionary alloc] init];

proDic=[jsonData JSONValue];
NSLog(@"%@",proDic);

关于iphone - 我已经在我的 IOS 应用程序中集成了 google plus,但是我无法获取当前登录用户的电子邮件 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13302904/

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