Python ADAL 庫的身份驗(yàn)證方法acquire_token_with_client_credentials不返回刷新令牌是否有原因?我想 Daemon 應(yīng)用程序不需要在每次運(yùn)行時(shí)都使用刷新令牌,但其他身份驗(yàn)證方法確實(shí)返回一個(gè)對(duì)我來說似乎很奇怪。代碼示例:class AzureActiveDirectory_Helper:_config = Configuration()_resource = _config.Resource_graph_api_endpoint = _config.Graph_API_Endpoint_authority = _config.Authoritydef __init__(self): self.Context = adal.AuthenticationContext(self._authority) self.Token = self.Context.acquire_token_with_client_credentials( resource=self._resource, client_id=self._config.Client_ID, client_secret="thisIsASuperSecretKey!!" ) self.Headers = { 'Authorization' : f'Bearer {self.Token["accessToken"]}', 'Accept' : 'application/json', 'Content-Type' : 'application/json' }self.Token 中的accessToken值確實(shí)有一個(gè)值,并且該令牌確實(shí)允許我針對(duì) Azure AD 應(yīng)用執(zhí)行我需要的操作,但是使用刷新令牌而不是每次運(yùn)行都獲取新令牌不是最佳實(shí)踐嗎?
1 回答

largeQ
TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
是的,我同意使用刷新令牌而不是每次都獲取新的新令牌是最佳做法。
使用客戶端憑據(jù)授予發(fā)布刷新令牌沒有任何好處。這就是為什么RFC6749 第 4.4.3 節(jié)指出不應(yīng)包含刷新令牌的原因。
根據(jù)文檔,“acquire_token_with_client_credentials”僅返回訪問令牌。
因此要使用刷新令牌,python adal 庫支持其他身份驗(yàn)證方法,例如:“acquire_token”、“acquire_token_with_refresh_token”等。您可以查看文檔。
以下是文檔鏈接:
https://adal-python.readthedocs.io/en/latest/
添加回答
舉報(bào)
0/150
提交
取消