o
    &zh                     @   sT   d dl mZ d dlmZ d dlmZmZmZ G dd deZe	eZ
e	eZdS )    )get_adapter)OAuth2Error)OAuth2AdapterOAuth2CallbackViewOAuth2LoginViewc                   @   s$   e Zd ZdZdZdZdZdd ZdS )TwitchOAuth2Adaptertwitchz!https://id.twitch.tv/oauth2/tokenz%https://id.twitch.tv/oauth2/authorizez!https://api.twitch.tv/helix/usersc                 K   s   d |j|jd}t  j| j|d}| }|jdkr2|dd}|dd}	t	d||	f z
|d	g d
 }
W n t
yI   t	d| w d|
vrTt	d|
 |  ||
S )Nz	Bearer {})Authorizationz	Client-ID)headersi  error messagezTwitch API Error: %s (%s)datar   z Invalid data from Twitch API: %sid)formattoken	client_idr   get_requests_sessiongetprofile_urljsonstatus_coder   
IndexErrorget_providersociallogin_from_response)selfrequestappr   kwargsr
   responser   r   r   	user_info r!   g/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/twitch/views.pycomplete_login   s$   

z"TwitchOAuth2Adapter.complete_loginN)__name__
__module____qualname__provider_idaccess_token_urlauthorize_urlr   r#   r!   r!   r!   r"   r   
   s    r   N)allauth.socialaccount.adapterr   -allauth.socialaccount.providers.oauth2.clientr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   r   adapter_viewoauth2_loginoauth2_callbackr!   r!   r!   r"   <module>   s    
 