U
    Zc                     @   sD   d dl Z d dlmZ d dlmZmZ ddlmZ G dd deZdS )    N)app_settings)OAuth2ClientOAuth2Error   )UntappdProviderc                   @   s   e Zd ZdZdddZdS )UntappdOAuth2Clientz
    Custom client because Untappd:
        * uses redirect_url instead of redirect_uri
        * nests access_token inside an extra 'response' object
    Nc           
      C   s   | j | jdd| j|d}d }| | | j}| jdkr>|}d }|rN|rN||d< tjt	j
i }d|ddi}tj| j||||d	}d }	|jd
kr| d }	|	rd|	krtd|j |	S )NZauthorization_codecode)Z	client_idZredirect_urlZ
grant_typeZresponse_typeZclient_secretr   GETZcode_verifierz
User-AgentZ
USER_AGENTzdjango-allauth)paramsdataheaders   responseaccess_tokenz!Error retrieving access token: %s)Zconsumer_keyZcallback_urlZconsumer_secretZ_strip_empty_keysZaccess_token_urlZaccess_token_methodr   Z	PROVIDERSgetr   idrequestsrequestZstatus_codejsonr   content)
selfr   Zpkce_code_verifierr   r
   urlsettingsr   Zrespr    r   r/var/www/html/crackeverytest/cet_env/lib/python3.8/site-packages/allauth/socialaccount/providers/untappd/client.pyget_access_token   s<    


z$UntappdOAuth2Client.get_access_token)N)__name__
__module____qualname____doc__r   r   r   r   r   r      s   r   )	r   Zallauth.socialaccountr   Z-allauth.socialaccount.providers.oauth2.clientr   r   Zproviderr   r   r   r   r   r   <module>   s   