o
    h
                     @   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)ProviderException)OAuth2AdapterOAuth2CallbackViewOAuth2LoginViewc                   @   s(   e Zd ZdZdZdZdZdZdd ZdS )	DataportenOAuth2Adapter
dataportenz&https://auth.dataporten.no/oauth/tokenz.https://auth.dataporten.no/oauth/authorizationz#https://auth.dataporten.no/userinfoz(https://groups-api.dataporten.no/groups/c                 K   sb   dd|j  i}t  j| j|d}|  | d }| d |jkr)td| 	 
||S )a  
        Arguments:
            request - The get request to the callback URL
                        /accounts/dataporten/login/callback.
            app - The corresponding SocialApp model instance
            token - A token object with access token given in token.token
        Returns:
            Should return a dict with user information intended for parsing
            by the methods of the DataportenProvider view, i.e.
            extract_uid(), extract_extra_data(), and extract_common_fields()
        AuthorizationzBearer )headersuseraudiencezDataporten returned a user with an audience field                  which does not correspond to the client id of the                  application.)tokenr   get_requests_sessiongetprofile_urlraise_for_statusjson	client_idr   get_providersociallogin_from_response)selfrequestappr   kwargsr
   userinfo_response
extra_data r   g/var/www/html/pos/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/dataporten/views.pycomplete_login   s$   	z&DataportenOAuth2Adapter.complete_loginN)	__name__
__module____qualname__provider_idaccess_token_urlauthorize_urlr   
groups_urlr   r   r   r   r   r   
   s    r   N)allauth.socialaccount.adapterr   $allauth.socialaccount.providers.baser   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   r   adapter_viewoauth2_loginoauth2_callbackr   r   r   r   <module>   s    
6