Python ADAL 库的身份验证方法acquire_token_with_client_credentials不返回刷新令牌是否有原因?我想 Daemon 应用程序不需要在每次运行时都使用刷新令牌,但其他身份验证方法确实返回一个对我来说似乎很奇怪。代码示例: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值确实有一个值,并且该令牌确实允许我针对 Azure AD 应用执行我需要的操作,但是使用刷新令牌而不是每次运行都获取新令牌不是最佳实践吗?
1 回答

largeQ
TA贡献2039条经验 获得超7个赞
是的,我同意使用刷新令牌而不是每次都获取新的新令牌是最佳做法。
使用客户端凭据授予发布刷新令牌没有任何好处。这就是为什么RFC6749 第 4.4.3 节指出不应包含刷新令牌的原因。
根据文档,“acquire_token_with_client_credentials”仅返回访问令牌。
因此要使用刷新令牌,python adal 库支持其他身份验证方法,例如:“acquire_token”、“acquire_token_with_refresh_token”等。您可以查看文档。
以下是文档链接:
https://adal-python.readthedocs.io/en/latest/
添加回答
举报
0/150
提交
取消