a
    Qx_h                     @   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 ZdS )UntappdOAuth2Clientz
    Custom client because Untappd:
        * uses redirect_url instead of redirect_uri
        * nests access_token inside an extra 'response' object
    c           	      C   s   | j | jdd| j|d}d }| | | j}| jdkr>|}d }tjt	j
i }d|ddi}tj| j||||d}d }|jd	kr| d
 }|rd|vrtd|j |S )NZauthorization_codecode)Z	client_idZredirect_urlZ
grant_typeZresponse_typeZclient_secretr   GETz
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   r   r
   urlsettingsr   Zrespr    r   f/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/untappd/client.pyget_access_token   s8    


z$UntappdOAuth2Client.get_access_tokenN)__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   