Revoking access tokens and disconnecting the app

It is highly recommended that you provide users that signed in with Google the ability to disconnect their Google account from your app. If the user deletes their account, you must delete the information that your app obtained from the Google APIs.

The following code example demonstrates how to programmatically revoke access tokens that your app was granted on behalf of the user and to disconnect the user's account from your app.

Swift

  GIDSignIn 
 . 
 sharedInstance 
 . 
 disconnect 
  
 { 
  
 error 
  
 in 
  
 guard 
  
 error 
  
 == 
  
 nil 
  
 else 
  
 { 
  
 return 
  
 } 
  
 // Google Account disconnected from your app. 
  
 // Perform clean-up actions, such as deleting data associated with the 
  
 //   disconnected account. 
 } 
 

Objective-C

  [ 
 GIDSignIn 
 . 
 sharedInstance 
  
 disconnectWithCompletion 
 :^ 
 ( 
 NSError 
  
 * 
  
 _Nullable 
  
 error 
 ) 
  
 { 
  
 if 
  
 ( 
 error 
 ) 
  
 { 
  
 return 
 ; 
  
 } 
  
 // Google Account disconnected from your app. 
  
 // Perform clean-up actions, such as deleting data associated with the 
  
 //   disconnected account. 
 }]; 
 

The disconnectWithCompletion: method signs the user out in addition to disconnecting their account and revoking tokens. You must not sign the user out before calling disconnectWithCompletion: .

You can then respond to the successful disconnection within the callback block and trigger any appropriate logic in your app or your back-end code.

Design a Mobile Site
View Site in Mobile | Classic
Share by: