App crashes on the request of access token

116 Views Asked by At

I am trying to get the access token using my authorization code:

curl --basic --user "{client_id}:{client_secret}" -X POST -d "grant_type=authorization_code&code={code}&state={state}" http://127.0.0.1:5000/oauth/token

I passed state parameter when I requested the authorization code:

http://127.0.0.1:5000/oauth/authorize?response_type=code&client_id={client_id}&state={state}

But my auth service responses:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

I checked execution in the debug mode, Authlib is trying to get state key in OAuthRequest but can't find it.
I can't get what am I doing wrong?

Routes:

@bp.route("/oauth/authorize", methods=['GET'])
@login_required
def authorize():
    user = current_user()
    return server.create_authorization_response(grant_user=user)


@bp.route('/oauth/token', methods=['POST'])
def issue_token():
    return server.create_token_response()
0

There are 0 best solutions below