code: def disconnect(remote):
      
      # User must be authenticated
      if not current_user.is_authenticated:
          return current_app.login_manager.unauthorized()
  
      external_method = 'github'
      external_ids = [i.id for i in current_user.external_identifiers
                      if i.method == external_method]
      if external_ids:
          oauth_unlink_external_id(dict(id=external_ids[0],
                                        method=external_method))
  
      user_id = int(current_user.get_id())
      token = RemoteToken.get(user_id, remote.consumer_key)
      if token:
          extra_data = token.remote_account.extra_data
  
          # Delete the token that we issued for GitHub to deliver webhooks
          webhook_token_id = extra_data.get('tokens', {}).get('webhook')
          ProviderToken.query.filter_by(id=webhook_token_id).delete()
  
          # Disable GitHub webhooks from our side
          db_repos = Repository.query.filter_by(user_id=user_id).all()
          # Keep repositories with hooks to pass to the celery task later on
          repos_with_hooks = [(r.github_id, r.hook) for r in db_repos if r.hook]
          for repo in db_repos:
              try:
                  Repository.disable(user_id=user_id,
                                     github_id=repo.github_id,
                                     name=repo.name)
              except NoResultFound:
                  # If the repository doesn't exist, no action is necessary
                  pass
          db.session.commit()
  
          # Send Celery task for webhooks removal and token revocation
          disconnect_github.delay(token.access_token, repos_with_hooks)
          # Delete the RemoteAccount (along with the associated RemoteToken)
          token.remote_account.delete()
  
      return redirect(url_for('invenio_oauthclient_settings.index'))
docs: Disconnect callback handler for GitHub.