API - add route to authorize oauth clients
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from typing import Dict, Tuple, Union
|
||||
|
||||
from flask import Blueprint, request
|
||||
from flask import Blueprint, Response, request
|
||||
|
||||
from fittrackee import db
|
||||
from fittrackee.responses import HttpResponse, InvalidPayloadErrorResponse
|
||||
@ -8,6 +8,7 @@ from fittrackee.users.decorators import authenticate
|
||||
from fittrackee.users.models import User
|
||||
|
||||
from .client import create_oauth_client
|
||||
from .server import authorization_server
|
||||
|
||||
oauth_blueprint = Blueprint('oauth', __name__)
|
||||
|
||||
@ -51,3 +52,16 @@ def create_client(auth_user: User) -> Union[HttpResponse, Tuple[Dict, int]]:
|
||||
},
|
||||
201,
|
||||
)
|
||||
|
||||
|
||||
@oauth_blueprint.route('/oauth/authorize', methods=['POST'])
|
||||
@authenticate
|
||||
def authorize(auth_user: User) -> Response:
|
||||
data = request.form
|
||||
if not data or 'client_id' not in data or 'response_type' not in data:
|
||||
return InvalidPayloadErrorResponse()
|
||||
|
||||
authorization_server.get_consent_grant(end_user=auth_user)
|
||||
return authorization_server.create_authorization_response(
|
||||
grant_user=auth_user
|
||||
)
|
||||
|
Reference in New Issue
Block a user