o
    Lf                     @   sH   d dl mZ d dlmZ d dlmZ d dlmZmZ G dd deZ	dS )    )OrderedDict)	urlencode)get_adapter)OAuth2ClientOAuth2Errorc                   @   s   e Zd Zdd ZdddZdS )WeixinOAuth2Clientc                 C   s^   | j | j| jdd}| jr| j|d< || t }t|D ]}|| ||< qd|t|f S )Ncode)appidredirect_uriscoperesponse_typestatez%s?%s)consumer_keycallback_urlr   r   updater   sortedr   )selfauthorization_urlextra_paramsparamssorted_paramsparam r   n/var/www/html/humari/django-venv/lib/python3.10/site-packages/allauth/socialaccount/providers/weixin/client.pyget_redirect_url   s   

z#WeixinOAuth2Client.get_redirect_urlNc                 C   s   | j | jd| j| j|d}d }| | | j}| jdkr |}d }|r(|r(||d< t  j	| j|||d}d }|j
dkr@| }|rFd|vrMtd|j |S )	Nauthorization_code)r	   r
   
grant_typesecretr   r   GETcode_verifier)r   data   access_tokenz!Error retrieving access token: %s)r   r   consumer_secretr   _strip_empty_keysaccess_token_urlaccess_token_methodr   get_requests_sessionrequeststatus_codejsonr   content)r   r   pkce_code_verifierr    r   urlrespr"   r   r   r   get_access_token   s4   


z#WeixinOAuth2Client.get_access_token)N)__name__
__module____qualname__r   r/   r   r   r   r   r      s    r   N)
collectionsr   django.utils.httpr   allauth.socialaccount.adapterr   -allauth.socialaccount.providers.oauth2.clientr   r   r   r   r   r   r   <module>   s
    