[英]How to Google OAuth Access Token in an iOs app using Objective C
我正在使用需要使用Google+ OAuth登录的iOS应用程序。 我需要从Google服务器获取访问令牌并将其发送到我的服务器进行身份验证。 使用其他语言对此有很多帮助,但对于目标C则没有。任何帮助都将非常有帮助
在应用程序委托中,通过定义以下方法,实现GIDSignInDelegate协议来处理登录过程:
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error {
// Perform any operations on signed in user here.
NSString *userId = user.userID; // For client-side use only!
NSString *idToken = user.authentication.idToken; // Safe to send to the server
NSString *name = user.profile.name;
NSString *email = user.profile.email;
// [START_EXCLUDE]
NSDictionary *statusText = @{@"statusText":
[NSString stringWithFormat:@"Signed in user: %@",
name]};
[[NSNotificationCenter defaultCenter]
postNotificationName:@"ToggleAuthUINotification"
object:nil
userInfo:statusText];
// [END_EXCLUDE]
}
// [END signin_handler]
这里指的这
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.