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)ProviderException)OAuth2AdapterOAuth2CallbackViewOAuth2LoginView   )DataportenProviderc                   @   s*   e Zd ZejZdZdZdZdZ	dd Z
dS )DataportenAdapterz&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   s\   dd|j  i}tj| j|d}|  | d }| d |jkrLt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()
        ZAuthorizationzBearer )headersuserZaudiencezDataporten returned a user with an audience field                  which does not correspond to the client id of the                  application.)
tokenrequestsgetprofile_urlZraise_for_statusjsonZ	client_idr   get_providerZsociallogin_from_response)selfrequestZappr   kwargsr	   Zuserinfo_response
extra_data r   h/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/dataporten/views.pycomplete_login   s    z DataportenAdapter.complete_loginN)__name__
__module____qualname__r   idZprovider_idZaccess_token_urlZauthorize_urlr   Z
groups_urlr   r   r   r   r   r      s   r   )r   Z$allauth.socialaccount.providers.baser   Z,allauth.socialaccount.providers.oauth2.viewsr   r   r   Zproviderr   r   Zadapter_viewZoauth2_loginZoauth2_callbackr   r   r   r   <module>   s   2
