
    )Jf	                         d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZmZ ddlmZ  G d	 d
e          Z ej        e          Z ej        e          ZdS )    )	timedelta)timezone)app_settings)get_adapter)SocialToken)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )LineProviderc                   8    e Zd Zej        ZdZdZdZdZ	d Z
d ZdS )LineOAuth2Adapterz%https://api.line.me/oauth2/v2.1/tokenz,https://access.line.me/oauth2/v2.1/authorizezhttps://api.line.me/v2/profilez&https://api.line.me/oauth2/v2.1/verifyc                    t           j                            | j        i           }d|                    dd          v rt	          |d                   }nt	          |d                   }|                    dd          |_        |                    | j        d          }|r6t          j                    t          t          |          	          z   |_        |S )
z3
        data: access_token data from line
        emailSCOPE id_token)tokenaccess_tokenrefresh_tokenN)seconds)r   	PROVIDERSgetprovider_idr   token_secretexpires_in_keyr   nowr   int
expires_at)selfdatasettingsr   
expires_ins        m/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/providers/line/views.pyparse_tokenzLineOAuth2Adapter.parse_token   s      )--d.>CChll7B////d:&6777EEd>&:;;;E!XXor::XXd1488
 	S'|~~	#j//0R0R0RRE    c                 Z   t           j                            | j        i           }d|                    dd          v rI|j        |j        d}t                                                                          | j	        |          }nVdd
                    |j                  i}t                                                                          | j        |          }|                                 |                                }	|                                                     ||	          S )Nr   r   r   )	client_idr   Authorizationz
Bearer {0})headers)r   r   r   r   r(   r   r   get_requests_sessionpostid_token_urlformatprofile_urlraise_for_statusjsonget_providersociallogin_from_response)
r    requestappr   kwargsr"   payloadrespr*   
extra_datas
             r$   complete_loginz LineOAuth2Adapter.complete_login(   s    )--d.>CChll7B////$'Mu{KKG==5577<<T=NPWXXDD&(;(;EK(H(HIG%%''T%w77 
 	YY[[
  ""<<WjQQQr&   N)__name__
__module____qualname__r   idr   access_token_urlauthorize_urlr/   r-   r%   r:    r&   r$   r   r      sS        /K>BM2K;L   R R R R Rr&   r   N)datetimer   django.utilsr   allauth.socialaccountr   allauth.socialaccount.adapterr   allauth.socialaccount.modelsr   ,allauth.socialaccount.providers.oauth2.viewsr   r	   r
   providerr   r   adapter_viewoauth2_loginoauth2_callbackrA   r&   r$   <module>rL      s         ! ! ! ! ! ! . . . . . . 5 5 5 5 5 5 4 4 4 4 4 4          # " " " " "%R %R %R %R %R %R %R %RP ,+,=>>1$12CDDr&   