ó
O'—^c           @   s:   d  d l  m Z d d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   BaseAuthenticationi   (   t   get_oauthlib_coret   OAuth2Authenticationc           B   s&   e  Z d  Z d Z d „  Z d „  Z RS(   sE   
    OAuth 2 authentication backend using `django-oauth-toolkit`
    t   apic         C   sB   t  ƒ  } | j | d g  ƒ\ } } | r: | j | j f Sd Sd S(   sk   
        Returns two-tuple of (user, token) if authentication succeeds,
        or None otherwise.
        t   scopesN(   R   t   verify_requestt   usert   access_tokent   None(   t   selft   requestt   oauthlib_coret   validt   r(    (    sS   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/ext/rest_framework/authentication.pyt   authenticate   s
    	c         C   s   d |  j  S(   s=   
        Bearer is the only finalized type currently
        s   Bearer realm="%s"(   t   www_authenticate_realm(   R	   R
   (    (    sS   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/ext/rest_framework/authentication.pyt   authenticate_header   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    sS   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/ext/rest_framework/authentication.pyR      s   	N(   t   rest_framework.authenticationR    t   oauth2_backendsR   R   (    (    (    sS   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/ext/rest_framework/authentication.pyt   <module>   s   