diff --git a/database/main.py b/database/main.py index 1711b80..9e1835f 100644 --- a/database/main.py +++ b/database/main.py @@ -107,5 +107,22 @@ def update_token_by_id(id): db.session.commit() return '', 204 +# get all tokens +@app.route('/token/all', methods=['GET']) +def get_all_tokens(): + tokens = Token.query.all() + tokens_info = [{ + 'id': token.id, + 'email': token.email, + 'access_token': token.access_token, + 'refresh_token': token.refresh_token, + 'expiration_seconds': int(token.expiration_seconds), + 'readwise_api_key': token.readwise_api_key, + 'active': token.active, + 'created_at': int(token.created_at.timestamp()), + 'updated_at': int(token.updated_at.timestamp()) + } for token in tokens] + return jsonify({'tokens': tokens_info}), 200 + if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True)