def add_refresh_token(db_session, user): refresh_token = "abcde1234567kposjdas" expires = int(time.time()) + 1000 db_session.add( UpstreamRefreshToken( refresh_token=refresh_token, user_id=user.id, expires=expires, )) db_session.commit()
def store_refresh_token(self, user, refresh_token, expires): """ Store refresh token in db. """ user.upstream_refresh_tokens = [] upstream_refresh_token = UpstreamRefreshToken( user=user, refresh_token=refresh_token, expires=expires, ) current_db_session = current_session.object_session( upstream_refresh_token) current_db_session.add(upstream_refresh_token) current_session.commit()