
    )Jf5                         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 )	    )app_settings)get_adapter)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )BitbucketOAuth2Providerc                   8    e Zd Zej        ZdZdZdZdZ	d Z
d ZdS )BitbucketOAuth2Adapterz.https://bitbucket.org/site/oauth2/access_tokenz+https://bitbucket.org/site/oauth2/authorizez"https://api.bitbucket.org/2.0/userz)https://api.bitbucket.org/2.0/user/emailsc                 n   t                                                                          | j        d|j        i          }|                                }t          j        r-|                    d          s|                     |          |d<   | 	                                
                    ||          S )Naccess_tokenparamsemail)r   get_requests_sessiongetprofile_urltokenjsonr   QUERY_EMAIL	get_emailget_providersociallogin_from_response)selfrequestappr   kwargsresp
extra_datas          y/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/providers/bitbucket_oauth2/views.pycomplete_loginz%BitbucketOAuth2Adapter.complete_login   s    MM!!##S!>5;*GSHH 	
 YY[[
# 	8JNN7,C,C 	8"&.."7"7Jw  ""<<WjQQQ    c                    t                                                                          | j        d|j        i          }|                                                    dg           }d}	 |d                             d          }d |D             }|d                             d          }n# t          t          t          f$ r Y |S w xY w	 |S # |c cY S xY w)z-Fetches email address from email API endpointr   r   values r   r   c                 >    g | ]}|                     d d          |S )
is_primaryF)r   ).0es     r    
<listcomp>z4BitbucketOAuth2Adapter.get_email.<locals>.<listcomp>)   s+    NNNA155u3M3MNaNNNr"   )	r   r   r   
emails_urlr   r   
IndexError	TypeErrorKeyError)r   r   r   emailsr   primary_emailss         r    r   z BitbucketOAuth2Adapter.get_email   s     MM!!##S.%+)FSGG 	
 2..	1IMM'**ENNNNNN"1%))'22EEIx0 	 	 	L	  L5LLLLLLLLs+   -AB0 /C 0CC 
CC CN)__name__
__module____qualname__r	   idprovider_idaccess_token_urlauthorize_urlr   r+   r!   r    r"   r    r   r      sR        ),KGAM6K<J	R 	R 	R    r"   r   N)allauth.socialaccountr   allauth.socialaccount.adapterr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   providerr	   r   adapter_viewoauth_loginoauth_callbackr8   r"   r    <module>r@      s    . . . . . . 5 5 5 5 5 5          . - - - - -" " " " "] " " "J +o*+ABB0#01GHHr"   