o
    iw
                     @   s   d dl Z d dlZd dlmZmZmZ d dlmZmZm	Z	 d dl
mZ d dlmZ ddlmZ ddlmZ d	ZG d
d deZdedee fddZdedededefddZdS )    N)DictOptionalAny)AccessTokenAccessTokenInfoTokenRequestOptions)ClientAuthenticationError)HttpRequest   )EnvironmentVariables)MsalManagedIdentityClienta  Specifying a client_id or identity_config is not supported by the Service Fabric managed identity environment. The managed identity configuration is determined by the Service Fabric cluster resource configuration. See https://aka.ms/servicefabricmi for more information.c                       sz   e Zd ZddedefddZdddded	ee d
ee dedef
 fddZdddedee	 de
f fddZ  ZS )ServiceFabricCredential descreturnc                 C   s
   d| S )NzHService Fabric managed identity configuration not found in environment.  )selfr   r   r   a/home/app/Keep/.python/lib/python3.10/site-packages/azure/identity/_credentials/service_fabric.pyget_unavailable_message   s   
z/ServiceFabricCredential.get_unavailable_messageNclaims	tenant_idscopesr   r   kwargsc                   s:   | j ds| j drttdt j|||d|S )N	client_ididentity_configmessager   )	_settingsgetr   SERVICE_FABRIC_ERROR_MESSAGEsuper	get_token)r   r   r   r   r   	__class__r   r   r"      s   
z!ServiceFabricCredential.get_token)optionsr%   c                   s4   | j ds| j drttdt j|d|iS )Nr   r   r   r%   )r   r   r   r    r!   get_token_info)r   r%   r   r#   r   r   r&   #   s   
z&ServiceFabricCredential.get_token_info)r   )__name__
__module____qualname__strr   r   r   r   r"   r   r   r&   __classcell__r   r   r#   r   r      s    ,r   r   r   c                  K   sV   t jtj}t jtj}t jtj}|r|r|sd S t| d|idt	t
|dS )NZSecretF)base_headersZconnection_verifyZrequest_factory)osenvironr   r   ZIDENTITY_ENDPOINTZIDENTITY_HEADERZIDENTITY_SERVER_THUMBPRINTdict	functoolspartial_get_request)r   urlsecretZ
thumbprintr   r   r   _get_client_args)   s   
r5   r3   scoper   c                 C   s    t d| td|dfi |dS )NGETz2019-07-01-preview)zapi-versionresource)params)r	   r/   )r3   r6   r   r   r   r   r2   9   s   r2   )r0   r-   typingr   r   r   Zazure.core.credentialsr   r   r   Zazure.core.exceptionsr   Zazure.core.restr	   
_constantsr   Z&_internal.msal_managed_identity_clientr   r    r   r5   r*   r2   r   r   r   r   <module>   s   