def save_token(token, request, *args, **kwargs): Token.delete_by_client_and_user(request.client.client_id, request.user.id) expires = datetime.now() + timedelta(seconds=_THOUSAND_DAY) return Token.create( request.client.client_id, request.user.id, token["token_type"], token["access_token"], token["refresh_token"], expires, token["scope"], )
def delete_token(): token_id = request.form['token'] token = Token.get(token_id) if not token: return jsonify({'message': 'not found'}), 404 if token.user_id != g.user.id: return jsonify({'message': 'not allowed'}), 403 token.delete() return jsonify({'message': 'ok'})
def delete_token(): token_id = request.form["token"] token = Token.get(token_id) if not token: return {"message": "not found"}, 404 if token.user_id != g.user.id: return {"message": "not allowed"}, 403 token.delete() return {"message": "ok"}
def load_token(access_token=None, refresh_token=None): if access_token: return Token.get_by_access(access_token) return Token.get_by_refresh(refresh_token)
def authorized_tokens(): tokens = Token.get_by_user(g.user.id, g.start, g.limit) return render_template('authorized.html', tokens=tokens)