12
12
import azure .identity .aio
13
13
14
14
if TYPE_CHECKING :
15
+ from collections .abc import Iterable
16
+
15
17
from obstore .store import AzureCredential
16
18
17
19
AzureCredentialUnionType = (
55
57
| azure .identity .aio .WorkloadIdentityCredential
56
58
)
57
59
60
+ DEFAULT_SCOPES = ("https://storage.azure.com/.default" ,)
61
+
58
62
59
63
class AzureCredentialProvider :
60
64
"""A CredentialProvider for [AzureStore][obstore.store.AzureStore] that uses [`azure.identity`][].
@@ -80,7 +84,7 @@ class AzureCredentialProvider:
80
84
def __init__ (
81
85
self ,
82
86
credential : AzureCredentialUnionType | None = None ,
83
- scopes : list [str ] | None = None ,
87
+ scopes : Iterable [str ] = DEFAULT_SCOPES ,
84
88
tenant_id : str | None = None ,
85
89
) -> None :
86
90
"""Create a new AzureCredentialProvider.
@@ -90,18 +94,15 @@ def __init__(
90
94
in which case [`azure.identity.DefaultAzureCredential`][] will be
91
95
called to find default credentials.
92
96
scopes: Scopes required by the access token. If not specified,
93
- [ "https://storage.azure.com/.default"] will be used by default.
97
+ ( "https://storage.azure.com/.default",) will be used by default.
94
98
tenant_id: Optionally specify the Azure Tenant ID which will be passed to
95
99
the credential's `get_token` method.
96
100
97
101
[`azure.identity.DefaultAzureCredential`]: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential
98
102
99
103
"""
100
104
self .credential = credential or azure .identity .DefaultAzureCredential ()
101
-
102
- # Use the Azure Storage scope by default
103
- self .scopes = scopes or ["https://storage.azure.com/.default" ]
104
-
105
+ self .scopes = scopes
105
106
self .tenant_id = tenant_id
106
107
107
108
# Token cache
@@ -152,7 +153,7 @@ class AzureAsyncCredentialProvider:
152
153
def __init__ (
153
154
self ,
154
155
credential : AzureAsyncCredentialUnionType | None = None ,
155
- scopes : list [str ] | None = None ,
156
+ scopes : Iterable [str ] = DEFAULT_SCOPES ,
156
157
tenant_id : str | None = None ,
157
158
) -> None :
158
159
"""Create a new AzureAsyncCredentialProvider.
@@ -162,18 +163,15 @@ def __init__(
162
163
in which case [`azure.identity.aio.DefaultAzureCredential`][] will be
163
164
called to find default credentials.
164
165
scopes: Scopes required by the access token. If not specified,
165
- [ "https://storage.azure.com/.default"] will be used by default.
166
+ ( "https://storage.azure.com/.default",) will be used by default.
166
167
tenant_id: Optionally specify the Azure Tenant ID which will be passed to
167
168
the credential's `get_token` method.
168
169
169
170
[`azure.identity.aio.DefaultAzureCredential`]: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.aio.defaultazurecredential
170
171
171
172
"""
172
173
self .credential = credential or azure .identity .aio .DefaultAzureCredential ()
173
-
174
- # Use the Azure Storage scope by default
175
- self .scopes = scopes or ["https://storage.azure.com/.default" ]
176
-
174
+ self .scopes = scopes
177
175
self .tenant_id = tenant_id
178
176
179
177
# Token cache
0 commit comments