o
    Lfk                     @   sH   d dl m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 )	    )app_settings)get_adapter)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 }|r'|r'||d< tjt	j
i }d|ddi}t  j| j||||d	}d }	|jd
krR| d }	|	rXd|	vr_td|j |	S )Nauthorization_codecode)	client_idredirect_url
grant_typeresponse_typeclient_secretr
   GETcode_verifierz
User-Agent
USER_AGENTzdjango-allauth)paramsdataheaders   responseaccess_tokenz!Error retrieving access token: %s)consumer_keycallback_urlconsumer_secret_strip_empty_keysaccess_token_urlaccess_token_methodr   	PROVIDERSgetr   idr   get_requests_sessionrequeststatus_codejsonr   content)
selfr
   pkce_code_verifierr   r   urlsettingsr   respr    r,   o/var/www/html/humari/django-venv/lib/python3.10/site-packages/allauth/socialaccount/providers/untappd/client.pyget_access_token   sB   


z$UntappdOAuth2Client.get_access_token)N)__name__
__module____qualname____doc__r.   r,   r,   r,   r-   r      s    r   N)
allauth.socialaccountr   allauth.socialaccount.adapterr   -allauth.socialaccount.providers.oauth2.clientr   r   providerr   r   r,   r,   r,   r-   <module>   s
    