D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
lib
/
python3.6
/
site-packages
/
oauthlib
/
oauth1
/
rfc5849
/
endpoints
/
__pycache__
/
Filename :
resource.cpython-36.pyc
back
Copy
3 ,�[ � @ sR d Z ddlmZmZ ddlZddlmZ ddlmZ ej e �ZG dd � d e�ZdS ) z� oauthlib.oauth1.rfc5849.endpoints.resource ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of the resource protection provider logic of OAuth 1.0 RFC 5849. � )�absolute_import�unicode_literalsN� )�errors� )�BaseEndpointc @ s e Zd ZdZddd�ZdS )�ResourceEndpointa! An endpoint responsible for protecting resources. Typical use is to instantiate with a request validator and invoke the ``validate_protected_resource_request`` in a decorator around a view function. If the request is valid, invoke and return the response of the view. If invalid create and return an error response directly from the decorator. See :doc:`/oauth1/validator` for details on which validator methods to implement for this endpoint. An example decorator:: from functools import wraps from your_validator import your_validator from oauthlib.oauth1 import ResourceEndpoint endpoint = ResourceEndpoint(your_validator) def require_oauth(realms=None): def decorator(f): @wraps(f) def wrapper(request, *args, **kwargs): v, r = provider.validate_protected_resource_request( request.url, http_method=request.method, body=request.data, headers=request.headers, realms=realms or []) if v: return f(*args, **kwargs) else: return abort(403) �GETNc C s� y| j ||||�}W n tjk r* dS X y| j|� | j|� W n tjk r^ d|fS X |jsnd|fS | jj|j�s�d|fS | jj|j |j |j||jd�s�d|fS | jj|j |�}|s�| jj |_ | jj|j |j|�}|� s�| jj|_| jj|j |j||j|d�} | j|�} ||jd<