【发布时间】:2015-08-22 11:22:54
【问题描述】:
我正在开发一个需要使用 Google+ OAuth 登录的 iOS 应用程序。我需要从谷歌服务器获取访问令牌并将其发送到我的服务器进行身份验证。使用其他语言有很多帮助,但不是针对 Objective C 的。任何帮助都会非常有帮助
【问题讨论】:
-
你读过this中的任何个
标签: ios objective-c oauth google-plus google-oauth
我正在开发一个需要使用 Google+ OAuth 登录的 iOS 应用程序。我需要从谷歌服务器获取访问令牌并将其发送到我的服务器进行身份验证。使用其他语言有很多帮助,但不是针对 Objective C 的。任何帮助都会非常有帮助
【问题讨论】:
标签: ios objective-c oauth google-plus google-oauth
在应用委托中,通过定义以下方法实现 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]
参考这里this
【讨论】: