iOS: Google Authentication Code

后端 未结 5 2204
刺人心
刺人心 2021-02-09 10:49

I am working with authenticating user to use the google account he is associated with. The problem is that everytime the user logs in through my app, the \"Allow Access\" always

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 11:35

    Put the below code to logout / sign out from Google SDK.
    
    - Call below function from where you want:
    
    static NSString *const kKeychainItemName = @"MY_APP";
    
    
    
    - (void)logoutFromGoogleDrive {
    
    [GTMOAuth2SignIn revokeTokenForGoogleAuthentication:(GTMOAuth2Authentication *)self.driveService.authorizer];
    
    [GTMOAuth2ViewControllerTouch saveParamsToKeychainForName:kKeychainItemName authentication:nil];
    
    }
    
    [Note: Above code works, if you have used GTMOAuth2SignIn  for sign in user for google access like,
    
    GTMOAuth2Authentication * auth = [GTMOAuth2ViewControllerTouch
    authForGoogleFromKeychainForName:YOUR_KEYCHAIN_ITEM_NAME
    clientID:GOOGLE_CLIENT_KEY
    clientSecret:GOOGLE_CLIENT_SECRET];
    
    ]
    

提交回复
热议问题