def tokens_delete(name=None, user=None, read_access_token=None, force=False):
    """Delete a personal OAuth token."""
    if not (name or user) and not read_access_token:
        click.get_current_context().fail(
            'You have to pass either a "name" and "user" or the "token"')
    if name and user:
        client = Client.query.filter(
            Client.user_id == user.id,
            Client.name == name,
            Client.is_internal.is_(True)).one()
        token = Token.query.filter(
            Token.user_id == user.id,
            Token.is_personal.is_(True),
            Token.client_id == client.client_id).one()
    elif read_access_token:
        access_token = click.prompt('Token', hide_input=True)
        token = Token.query.filter(Token.access_token == access_token).one()
    else:
        click.get_current_context().fail('No token was found with provided')
    if force or click.confirm('Are you sure you want to delete the token?'):
        db.session.delete(token)
        db.session.commit()
        click.secho(
            'Token "{}" deleted.'.format(token.access_token), fg='yellow')
def tokens_delete ( name = None , user = None , read_access_token = None , force = False ) : if not ( name or user ) and not read_access_token : click . get_current_context ( ) . fail ( 'You have to pass either a "name" and "user" or the "token"' ) if name and user : client = Client . query . filter ( Client . user_id == user . id , Client . name == name , Client . is_internal . is_ ( True ) ) . one ( ) token = Token . query . filter ( Token . user_id == user . id , Token . is_personal . is_ ( True ) , Token . client_id == client . client_id ) . one ( ) elif read_access_token : access_token = click . prompt ( 'Token' , hide_input = True ) token = Token . query . filter ( Token . access_token == access_token ) . one ( ) else : click . get_current_context ( ) . fail ( 'No token was found with provided' ) if force or click . confirm ( 'Are you sure you want to delete the token?' ) : db . session . delete ( token ) db . session . commit ( ) click . secho ( 'Token "{}" deleted.' . format ( token . access_token ) , fg = 'yellow' )
Delete a personal OAuth token.