
    )Jf                         d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
  G d de          Z ej        e          Z ej        e          ZdS )	zP
Views for PatreonProvider
https://www.patreon.com/platform/documentation/oauth
    )get_adapter)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )API_URL
USE_API_V2PatreonProviderc                   ^    e Zd Zej        ZdZdZd                    e	e
rdnd          Zd ZdS )PatreonOAuth2Adapterz(https://www.patreon.com/api/oauth2/tokenz(https://www.patreon.com/oauth2/authorizez{0}/{1}zidentity?include=memberships&fields%5Buser%5D=email,first_name,full_name,image_url,last_name,social_connections,thumb_url,url,vanitycurrent_userc                    t                                                                          | j        dd|j        z   i          }|                                                    d          }t          r	 |d         d         d         d         d         }d	                    t          |          }t                                                                          |dd|j        z   i          }	|	                                d
         d         d         d         }
|
|d<   n# t          t          f$ r d |d<   Y nw xY w|                                                     ||          S )NAuthorizationzBearer )headersdatarelationshipsmembershipsr   idzG{0}/members/{1}?include=currently_entitled_tiers&fields%5Btier%5D=titleincluded
attributestitlepledge_level)r   get_requests_sessiongetprofile_urltokenjsonr	   formatr   KeyError
IndexErrorget_providersociallogin_from_response)selfrequestappr   kwargsresp
extra_data	member_id
member_urlresp_memberpledge_titles              p/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/providers/patreon/views.pycomplete_loginz#PatreonOAuth2Adapter.complete_login   sk   MM!!##S ()ek*AB    	 YY[[__V,,
 	&7FvNqQRVW	F&),, 
  MM))++S"!0)ek2I J      +//11*=a@NwW-9
>**j)   -1
>*   ""<<WjQQQs   4B+D   D98D9N)__name__
__module____qualname__r
   r   provider_idaccess_token_urlauthorize_urlr   r   r	   r   r.        r-   r   r      sl        !$KA>M"" 	 	 	  K!R !R !R !R !Rr6   r   N)__doc__allauth.socialaccount.adapterr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   providerr   r	   r
   r   adapter_viewoauth2_loginoauth2_callbackr5   r6   r-   <module>r>      s    
 6 5 5 5 5 5          ; : : : : : : : : :.R .R .R .R .R= .R .R .Rb ,+,@AA1$12FGGr6   