
    AHj                     R    d Z ddlmZmZmZ ddlmZmZmZ erddl	Z	 G d de      Z
y)zSpotify SSO Login Helper.    )TYPE_CHECKINGClassVarOptional)DiscoveryDocumentOpenIDSSOBaseNc                   P    e Zd ZU dZdZddgZeed<   defdZ	dd	e
d
ed   defdZy)
SpotifySSOz(Class providing login via Spotify OAuth.spotifyzuser-read-privatezuser-read-emailscopereturnc                    K   ddddS w)z#Get document containing handy urls.z&https://accounts.spotify.com/authorizez&https://accounts.spotify.com/api/tokenzhttps://api.spotify.com/v1/me)authorization_endpointtoken_endpointuserinfo_endpoint )selfs    O/root/tools/cai/cai_env/lib/python3.12/site-packages/fastapi_sso/sso/spotify.pyget_discovery_documentz!SpotifySSO.get_discovery_document   s      'OF!@
 	
s   	Nresponsesessionzhttpx.AsyncClientc                    K   |j                  dg       r|d   d   d   nd}t        |j                  d      |j                  d      | j                  |j                  d      |      S w)	z8Return OpenID from user information provided by Spotify.imagesr   urlNemaildisplay_nameid)r   r   providerr   picture)getr   r   )r   r   r   r   s       r   openid_from_responsezSpotifySSO.openid_from_response   se     2:,,x2L(8$Q'.RV,,w'!n5]]||D!
 	
s   A'A))N)__name__
__module____qualname____doc__r   r   r   __annotations__r   r   dictr   r   r!   r       r   r
   r
      sH    2H*,=>E8>
.? 
	
4 	
(K^B_ 	
kq 	
r(   r
   )r%   typingr   r   r   fastapi_sso.sso.baser   r   r   httpxr
   r   r(   r   <module>r,      s&     4 4 C C
 
r(   