【问题标题】:How to Google OAuth Access Token in an iOs app using Objective C如何使用 Objective C 在 iOs 应用程序中使用 Google OAuth 访问令牌
【发布时间】:2015-08-22 11:22:54
【问题描述】:

我正在开发一个需要使用 Google+ OAuth 登录的 iOS 应用程序。我需要从谷歌服务器获取访问令牌并将其发送到我的服务器进行身份验证。使用其他语言有很多帮助,但不是针对 Objective C 的。任何帮助都会非常有帮助

【问题讨论】:

  • 你读过this中的任何

标签: ios objective-c oauth google-plus google-oauth


【解决方案1】:

在应用委托中,通过定义以下方法实现 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

【讨论】:

    猜你喜欢
    • 2012-06-21
    • 2015-02-25
    • 2017-06-26
    • 1970-01-01
    • 2011-04-16
    • 1970-01-01
    • 2013-05-30
    • 2013-11-11
    • 2018-02-05
    相关资源
    最近更新 更多