VisualStudioCodeCredential 類別

以透過「Azure 帳戶」擴充功能登入Visual Studio Code的 Azure 使用者進行驗證。

此認證不適用於0.9.11之前的Azure 帳戶擴充功能版本。這是已知問題。 此問題的長期修正正在進行中。 同時,請考慮使用 AzureCliCredential 進行驗證。

繼承
azure.identity._credentials.vscode._VSCodeCredentialBase
VisualStudioCodeCredential
azure.identity._internal.get_token_mixin.GetTokenMixin
VisualStudioCodeCredential

建構函式

VisualStudioCodeCredential(**kwargs: Any)

參數

authority
str

Azure Active Directory 端點的授權單位,例如「login.microsoftonline.com」。 自訂雲端需要這個引數,否則通常不需要。 預設為符合 VS Code 使用者設定中 「Azure: Cloud」設定的授權單位,或當該設定沒有值時,Azure 公用雲端的授權單位。

tenant_id
str

認證應該驗證的租使用者識別碼。 預設為 VS Code 使用者設定中的 「Azure: Tenant」設定,或當該設定沒有值時,「組織」租使用者僅支援 Azure Active Directory 公司或學校帳戶。

additionally_allowed_tenants
List[str]

除了認證可能會取得權杖的指定「tenant_id」之外,指定租使用者。 新增萬用字元值 「*」,以允許認證取得應用程式可存取之任何租使用者的權杖。

方法

close

關閉認證的傳輸會話。

get_token

要求範圍存取權杖,因為使用者目前已登入Visual Studio Code。

Azure SDK 用戶端會自動呼叫此方法。

close

關閉認證的傳輸會話。

close() -> None

get_token

要求範圍存取權杖,因為使用者目前已登入Visual Studio Code。

Azure SDK 用戶端會自動呼叫此方法。

get_token(*scopes: str, claims: str | None = None, tenant_id: str | None = None, **kwargs: Any) -> AccessToken

參數

scopes
str
必要

存取權杖所需的範圍。 此方法至少需要一個範圍。 如需範圍的詳細資訊,請參閱 https://learn.microsoft.com/azure/active-directory/develop/scopes-oidc

claims
str

權杖中所需的其他宣告,例如在授權失敗之後,在資源提供者的宣告挑戰中傳回的其他宣告。

tenant_id
str

要包含在權杖要求中的選擇性租使用者。

傳回

具有所需範圍的存取權杖。

傳回類型

例外狀況

認證無法從Visual Studio Code擷取使用者詳細資料