gpt4 book ai didi

azure - 为什么在 Azure 中使用 AD token 访问存储帐户 90 分钟后不会过期?

转载 作者:行者123 更新时间:2023-12-03 05:19:37 26 4
gpt4 key购买 nike

这是代码

from azure.identity import ClientSecretCredential

token_credential = ClientSecretCredential(
"",# tenant id
"",# active directory application id
"", # active directory application secret
)

blob_service_client = BlobServiceClient(account_url=oauth_url, credential=token_credential)



def listcontainer():
from azure.storage.blob import BlobServiceClient
con = blob_service_client.list_containers()
for x in con:
print(x)


while True:
end = int(time.time())
if end - start > 4800:
break
else:
print("run time in minute: ", (end - start) / 60)
try:
listcontainer()
except Exception as e:
print("exception reached")
print(e)
break
time.sleep(60)

我设置了 BlobServiceClient 一次,预计 90 分钟后会出现异常

但是我没有看到这种情况发生

在本文档中

https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes

The default lifetime of an access token is variable. When issued, an access token's default lifetime is assigned a random value ranging between 60-90 minutes (75 minutes on average). The default lifetime also varies depending on the client application requesting the token or if conditional access is enabled in the tenant. For more information, see Access token lifetime.

在这种情况下,过期与什么有关?

最佳答案

token 确实会过期,但 SDK 会在发生这种情况时自动更新它。作为用户,一般来说您无需担心。

关于azure - 为什么在 Azure 中使用 AD token 访问存储帐户 90 分钟后不会过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73288105/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com