a
    ‹Qx_a  ã                   @   s\   d dl Z 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 )é    N)Úapp_settings)ÚOAuth2AdapterÚOAuth2CallbackViewÚOAuth2LoginViewé   )ÚLinkedInOAuth2Providerc                   @   s6   e Zd ZejZdZdZdZdZ	dZ
dd„ Zdd	„ Zd
S )ÚLinkedInOAuth2Adapterz-https://www.linkedin.com/oauth/v2/accessTokenz/https://www.linkedin.com/oauth/v2/authorizationzhttps://api.linkedin.com/v2/mezRhttps://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))ÚGETc                 K   s   |   |¡}|  ¡  ||¡S )N)Úget_user_infoÚget_providerZsociallogin_from_response)ÚselfÚrequestZappÚtokenÚkwargsÚ
extra_data© r   úm/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/linkedin_oauth2/views.pyÚcomplete_login   s    
z$LinkedInOAuth2Adapter.complete_loginc                 C   s¢   |   ¡  ¡ }i }| |   ¡  ¡  di ¡¡ d d|jg¡|d< i }tjrft	j| j
|d}|jrf| ¡ }| jdd |¡  }t	j||d}| ¡  | | ¡ ¡ |S )NZHEADERSú ZBearerZAuthorization)Úheadersz?projection=(%s)ú,)r   Zget_profile_fieldsÚupdateZget_settingsÚgetÚjoinr   r   ZQUERY_EMAILÚrequestsÚ	email_urlÚokÚjsonÚprofile_urlZraise_for_status)r   r   Úfieldsr   ÚinfoZrespÚurlr   r   r   r
      s    z#LinkedInOAuth2Adapter.get_user_infoN)Ú__name__Ú
__module__Ú__qualname__r   ÚidZprovider_idZaccess_token_urlZauthorize_urlr   r   Zaccess_token_methodr   r
   r   r   r   r   r      s   r   )r   Zallauth.socialaccountr   Z,allauth.socialaccount.providers.oauth2.viewsr   r   r   Zproviderr   r   Zadapter_viewZoauth2_loginZoauth2_callbackr   r   r   r   Ú<module>   s   $
