
    iQ	                     j    S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  S	rS
r " S S\5      rg)zAuthentication helpers.    )DictN)PreparedRequest)AuthBase)IAMTokenManager   )cname_from_crnziam.cloud.ibm.comziam.test.cloud.ibm.comc                   z    \ rS rSrSrSS\S\S\4S jjrS\S\4S	 jr	S
\
S\
4S jrSS\SS 4S jjrS\4S jrSrg)	CloudAuth   z>Attaches IBM Cloud Authentication to the given Request object.api_keycrnprivatec                     X l         Xl        SU(       a  SOS [        U5      S:X  a  [        O[         3n[        XS9U l        g )Nzhttps://zprivate. staging)url)r   r   r   STAGING_CLOUD_IAM_URLCLOUD_IAM_URLr   tm)selfr   r   r   iam_urls        U/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/api/auth.py__init__CloudAuth.__init__   sF    Wz"5(6s(;y(H$m\^ 	 "'7    otherreturnc                     [        U[        5      (       a;  [        U R                  UR                  :H  U R                  UR                  :H  /5      $ g)NF)
isinstancer
   allr   r   )r   r   s     r   __eq__CloudAuth.__eq__(   sF    eY''LLEMM1HH		)  r   rc                 X    UR                   R                  U R                  5       5        U$ N)headersupdateget_headers)r   r#   s     r   __call__CloudAuth.__call__2   s"    			))+,r   N_memoc                 B    [        U R                  U R                  S9nU$ )N)r   r   )r
   r   r   )r   r+   cpys      r   __deepcopy__CloudAuth.__deepcopy__6   s!    LL
 
r   c                      U R                   R                  5       nU R                  SU 3S.$ ! [         a?  n[        R
                  " SU 35        U R                  SU R                   3S.s SnA$ SnAff = f)z8Return authorization information to be stored in header.zBearer )zService-CRNAuthorizationzIUnable to retrieve IBM Cloud access token. API Key will be used instead. zapikey N)r   	get_tokenr   	Exceptionwarningswarnr   )r   access_tokenexs      r   r(   CloudAuth.get_headers=   sv    	X77,,.L#'88~>VWW 	XMM[\^[_` $(88~>VWW		Xs   +. 
A74A2,A72A7)r   r   r   )Fr%   )__name__
__module____qualname____firstlineno____doc__strboolr   objectr!   r   r)   dictr.   r   r(   __static_attributes__ r   r   r
   r
      sf    H8 8# 8 8F t / o $ + 	XT 	Xr   r
   )r=   typingr   r4   requestsr   requests.authr   ibm_cloud_sdk_corer   utils.utilsr   r   r   r
   rC   r   r   <module>rI      s5       $ " . (#0 *X *Xr   