add token.api_id

id key used in rest api
This commit is contained in:
Min RK
2018-04-13 16:08:43 +02:00
parent f7f0b72776
commit 30280cc6a4
2 changed files with 9 additions and 3 deletions

View File

@@ -342,6 +342,10 @@ class APIToken(Hashed, Base):
hashed = Column(Unicode(255), unique=True)
prefix = Column(Unicode(16), index=True)
@property
def api_id(self):
return 'a%i' % self.id
# token metadata for bookkeeping
created = Column(DateTime, default=datetime.utcnow)
last_activity = Column(DateTime)
@@ -431,6 +435,10 @@ class OAuthAccessToken(Hashed, Base):
__tablename__ = 'oauth_access_tokens'
id = Column(Integer, primary_key=True, autoincrement=True)
@property
def api_id(self):
return 'o%i' % self.id
client_id = Column(Unicode(255), ForeignKey('oauth_clients.identifier', ondelete='CASCADE'))
grant_type = Column(Enum(GrantType), nullable=False)
expires_at = Column(Integer)