"""Api Token Model. The API tokens grant permissions to clients (identified by their client id) to access specific API endpoints on the behalf of a user (identified by its id). All tokens have an expiration date. Warning: In the current design and database implementation, one client can have more than one oauth_token for a specific user. """ from sqlalchemy import Column, Enum, Integer, String from grass import config from grass.connectors import mysql class ApiToken(mysql.BaseModel): """Api Token Model.""" __tablename__ = 'vectorapi_access_tokens' oauth_token = Column(String, primary_key=True) client_id = Column(String) user_id = Column(Integer) user_type = Column(Enum('alw', 'oa')) expires_REMOVE = Column(Integer) if config.environment == config.TEST_ENVIRONMENT: ApiToken.__table__.create(mysql.engine)