如何延长 MSAL Python 库的访问令牌过期时间?
How to extend access token expiration time for MSAL Python library?
使用 Python 的 MSAL 库时,我无法更改默认的 1 小时访问令牌过期时间。
我试过:
now = datetime.datetime.utcnow()
then = datetime.datetime.utcnow() + datetime.timedelta(minutes=10)
claims = {
"exp": then,
}
app = msal.ConfidentialClientApplication(
graph_config["client_id"], authority=graph_config["authority"],
client_credential=graph_config["secret"], client_claims=claims)
我试过将其作为 python 日期时间对象和字符串发送。我尝试将“_min”添加到值中,并且我已经尝试过 'now + 10_min' 就像文档所说的那样。
无论如何,我仍然得到一个过期时间:
"expires_in": 3599,
"ext_expires_in": 3599,
即一小时
为了所有圣洁的爱,请有人帮助我让这个愚蠢的访问令牌持续更长时间。
令牌生命周期由 Azure AD https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties 中的策略管理,因此您不能从用户级别更改它们(但管理员可以更改或创建新策略来执行此操作)。出于安全原因,默认生命周期为 1 小时,除非您有充分的理由更改它,否则您不应该更改它,因为它通常很容易让任何应用程序管理自己的令牌 refresh/renew.
使用 Python 的 MSAL 库时,我无法更改默认的 1 小时访问令牌过期时间。
我试过:
now = datetime.datetime.utcnow()
then = datetime.datetime.utcnow() + datetime.timedelta(minutes=10)
claims = {
"exp": then,
}
app = msal.ConfidentialClientApplication(
graph_config["client_id"], authority=graph_config["authority"],
client_credential=graph_config["secret"], client_claims=claims)
我试过将其作为 python 日期时间对象和字符串发送。我尝试将“_min”添加到值中,并且我已经尝试过 'now + 10_min' 就像文档所说的那样。
无论如何,我仍然得到一个过期时间:
"expires_in": 3599,
"ext_expires_in": 3599,
即一小时
为了所有圣洁的爱,请有人帮助我让这个愚蠢的访问令牌持续更长时间。
令牌生命周期由 Azure AD https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties 中的策略管理,因此您不能从用户级别更改它们(但管理员可以更改或创建新策略来执行此操作)。出于安全原因,默认生命周期为 1 小时,除非您有充分的理由更改它,否则您不应该更改它,因为它通常很容易让任何应用程序管理自己的令牌 refresh/renew.