a
    |_Y                     @   sP   d dl 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)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )QuickBooksOAuth2Providerc                   @   s:   e Zd ZejZdZdZdZdZ	dZ
dZdd Zd	d
 ZdS )QuickBooksOAuth2Adapterz9https://oauth.platform.intuit.com/oauth2/v1/tokens/bearerz+https://appcenter.intuit.com/connect/oauth2zGhttps://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfoz?https://accounts.platform.intuit.com/v1/openid_connect/userinfoGETZPOSTc                 K   s2   |j d}| |}|r"||d< |  ||S )NZrealmId)r   getget_user_infoget_providerZsociallogin_from_response)selfrequestZapptokenkwargsZrealm_id
extra_data r   h/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/quickbooks/views.pycomplete_login   s
    
z&QuickBooksOAuth2Adapter.complete_loginc                 C   sX   d|j  }d|dd}|   dd}|r4| jn| j}tj||d}|  | S )NzBearer zapplication/json)ZAcceptZAuthorizationacceptZSANDBOXF)headers)	r   r   Zget_settingsr	   profile_testprofile_urlrequestsZraise_for_statusjson)r   r   Zauth_headerr   Z
is_sandboxurlZrespr   r   r   r
      s    
z%QuickBooksOAuth2Adapter.get_user_infoN)__name__
__module____qualname__r   idZprovider_idZaccess_token_urlZauthorize_urlr   r   Zprofile_url_methodZaccess_token_methodr   r
   r   r   r   r   r      s   r   )r   Z,allauth.socialaccount.providers.oauth2.viewsr   r   r   Zproviderr   r   Zadapter_viewZoauth2_loginZoauth2_callbackr   r   r   r   <module>   s
   
