o
    i6                     @   sP   d Z ddlmZmZmZ ddlmZmZmZm	Z	 erddl
Z
G dd deZdS )zNotion SSO Oauth Helper class.    )TYPE_CHECKINGClassVarOptional)DiscoveryDocumentOpenIDSSOBaseSSOLoginErrorNc                   @   s^   e Zd ZU dZdZdgZeed< ddiZeed< de	fd	d
Z
ddeded defddZdS )	NotionSSOz)Class providing login using Notion OAuth.ZnotionZopenidscopezNotion-Versionz
2022-06-28additional_headersreturnc                    s   ddddS )Nz4https://api.notion.com/v1/oauth/authorize?owner=userz%https://api.notion.com/v1/oauth/tokenz"https://api.notion.com/v1/users/me)Zauthorization_endpointZtoken_endpointZuserinfo_endpoint )selfr   r   M/home/app/Keep/.python/lib/python3.10/site-packages/fastapi_sso/sso/notion.pyget_discovery_document   s
   z NotionSSO.get_discovery_documentNresponsesessionzhttpx.AsyncClientc                    sn   |d d }|d dkrt dd|d d d  t|d d |d d d	 |d d
 |d d | jdS )NZbotownertypeuseri  z-Notion login failed, owner is not a user but idZpersonemailZ
avatar_urlname)r   r   ZpictureZdisplay_nameprovider)r   r   r   )r   r   r   r   r   r   r   openid_from_response   s   


zNotionSSO.openid_from_response)N)__name__
__module____qualname____doc__r   r
   r   __annotations__r   r   r   dictr   r   r   r   r   r   r   r	      s   
  r	   )r   typingr   r   r   Zfastapi_sso.sso.baser   r   r   r   Zhttpxr	   r   r   r   r   <module>   s    