コード例 #1
0
def get_token(*args, **kwargs):
    """
    Handle exchanging code for and refreshing the access token.

    See the OpenAPI documentation for detailed specification, and the OAuth2
    tests for examples of some operation and correct behavior.
    """
    return server.create_token_response()
コード例 #2
0
ファイル: oauth2.py プロジェクト: stefan2811/fence
def get_token(*args, **kwargs):
    """
    Handle exchanging code for and refreshing the access token.

    The operation here is handled entirely by the ``oauth.token_handler``
    decorator, so this function only needs to pass.

    See the OpenAPI documentation for detailed specification, and the OAuth2
    tests for examples of some operation and correct behavior.
    """
    return server.create_token_response()
コード例 #3
0
ファイル: oauth2.py プロジェクト: qingyashu/fence
def get_token(*args, **kwargs):
    """
    Handle exchanging code for and refreshing the access token.

    See the OpenAPI documentation for detailed specification, and the OAuth2
    tests for examples of some operation and correct behavior.
    """
    try:
        response = server.create_token_response()
    except (JWTError, JWTExpiredError) as e:
        # - in Authlib 0.11, create_token_response does not raise OAuth2Error
        # - fence.jwt.errors.JWTError: blacklisted refresh token
        # - JWTExpiredError (cdiserrors.AuthNError subclass): expired
        #   refresh token
        # Returns code 400 per OAuth2 spec
        body = {"error": "invalid_grant", "error_description": e.message}
        response = flask.Response(
            json.dumps(body), mimetype="application/json", status=400
        )
    return response