o
    &zh                     @   sT   d dl mZ d dlmZmZmZ ddlmZ G dd deZe	eZ
e	eZdS )    )get_adapter)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )WeixinOAuth2Clientc                   @   s0   e Zd ZdZdZdZeZedd Z	dd Z
dS )	WeixinOAuth2Adapterweixinz1https://api.weixin.qq.com/sns/oauth2/access_tokenz&https://api.weixin.qq.com/sns/userinfoc                 C   s   |    }|dd}|S )NAUTHORIZE_URLz,https://open.weixin.qq.com/connect/qrconnect)get_providerget_settingsget)selfsettingsurl r   g/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/weixin/views.pyauthorize_url   s
   z!WeixinOAuth2Adapter.authorize_urlc           	      K   sr   | di  d}t  j | j|j|dd}|  | }| d}|r1|dd|d< | 	 
||S )Nresponseopenid)access_tokenr   )paramsnicknameraw_unicode_escapezutf-8)r   r   get_requests_sessionprofile_urltokenraise_for_statusjsonencodedecoder   sociallogin_from_response)	r   requestappr   kwargsr   resp
extra_datar   r   r   r   complete_login   s    


z"WeixinOAuth2Adapter.complete_loginN)__name__
__module____qualname__provider_idaccess_token_urlr   r   client_classpropertyr   r'   r   r   r   r   r      s    
r   N)allauth.socialaccount.adapterr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   clientr   r   adapter_viewoauth2_loginoauth2_callbackr   r   r   r   <module>   s    
"