Like this article? We recommend
Revoking Access
Revoking Access
Google’s developer guidelines require that users have a way to disassociate their account from an application. It’s important to note your responsibility is to only sever the link and revoke any client tokens so that you can’t make any API requests on their behalf. Any data that you obtained from the API must be deleted in a timely manner if the user chooses to do so. I used the following snippet to revoke the connection (logout but not purging data). If the revocation results in an error, it redirects to the Apps section of the users’ Google+ profile and allows them to manage the connection there.
function revokeConnection() { var access_token = gapi.auth.getToken().access_token; var url = 'https://accounts.google.com/o/oauth2/revoke?token=' + access_token; try { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); xhr.onload = function(response) { if (this.status == 200) { // success console.log("User disconnected"); } } xhr.send(); localStorage.removeItem('name'); localStorage.removeItem('imageUrl') } catch (error) { window.location = 'https://plus.google.com/apps'; } }