Revoking access tokens and disconnecting the app

  • Apps should allow users who signed in with Google to disconnect their Google account.

  • Upon account deletion, app developers must delete user data obtained via Google APIs.

  • Provided code snippets (Swift & Objective-C) show how to revoke access tokens and disconnect a user's Google account.

  • disconnectWithCompletion: handles sign-out, disconnection, and token revocation - do not sign the user out beforehand.

  • Developers should implement logic within the callback to handle successful disconnections and trigger necessary actions.

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.