def decorated(*args, **kwargs): token_type, token = get_token() if request.method != 'OPTIONS': if token_type is None or token_type.lower() != 'bearer': return api_abort(400, 'The token type must be bearer.') if token is None: return token_missing() if not validate_token(token): return invalid_token() return f(*args, **kwargs)
def decorated(*args, **kwargs): token_type, token = get_token() # Flask normally handles OPTIONS requests on its own, but in the # case it is configured to forward those to the application, we # need to ignore authentication headers and let the request through # to avoid unwanted interactions with CORS. if request.method != 'OPTIONS': if token_type is None or token_type.lower() != 'bearer': return api_abort(400, 'The token type must be bearer!') if token is None: return token_missing() if not validate_token(token): return invalid_token() return f(*args, **kwargs)
def decorated(*args, **kwargs): token_type, token = get_token() # Flask normally handles OPTIONS requests on its own, but in the # case it is configured to forward those to the application, we # need to ignore authentication headers and let the request through # to avoid unwanted interactions with CORS. # 翻译: Flask通常独立处理OPTIONS请求,但是如果配置为将这些请求转发给应用程序,我们需要忽略身份验证头, # 让请求通过,以避免与CORS的不必要的交互。 if request.method != 'OPTIONS': if token_type is None or token_type.lower() != 'bearer': print(token_type) return api_abort(400, 'The token type must be bearer.') if token is None: return token_missing() if not validate_token(token): return invalid_token() return f(*args, **kwargs)