a
    Qx_                     @   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)OAuth2Error)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )TwitchProviderc                   @   s&   e Zd ZejZdZdZdZdd Z	dS )TwitchOAuth2Adapterz!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r^|dd}|dd}	td||	f z|d	g d
 }
W n t	y   td| Y n0 d|
vrtd|
 | 
 ||
S )Nz	Bearer {})ZAuthorizationz	Client-ID)headersi  error messagezTwitch API Error: %s (%s)datar   z Invalid data from Twitch API: %sid)formattokenZ	client_idrequestsgetprofile_urljsonZstatus_coder   
IndexErrorget_providerZsociallogin_from_response)selfrequestZappr   kwargsr	   responser   r
   r   Z	user_info r   d/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/twitch/views.pycomplete_login   s     

z"TwitchOAuth2Adapter.complete_loginN)
__name__
__module____qualname__r   r   Zprovider_idZaccess_token_urlZauthorize_urlr   r   r   r   r   r   r      s
   r   )r   Z-allauth.socialaccount.providers.oauth2.clientr   Z,allauth.socialaccount.providers.oauth2.viewsr   r   r   Zproviderr   r   Zadapter_viewZoauth2_loginZoauth2_callbackr   r   r   r   <module>   s   
