[英]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.