22// Licensed under the MIT License.
33
44use azure_core:: {
5- credentials:: { AccessToken , TokenCredential } ,
5+ credentials:: { AccessToken , TokenCredential , TokenRequestOptions } ,
66 error:: { ErrorKind , ResultExt } ,
77 Error ,
88} ;
@@ -25,7 +25,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2525 let url = url:: Url :: parse ( & format ! ( "https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01" ) ) ?;
2626
2727 let access_token = credential
28- . get_token ( & [ "https://management.azure.com/.default" ] )
28+ . get_token ( & [ "https://management.azure.com/.default" ] , None )
2929 . await ?;
3030
3131 let response = reqwest:: Client :: new ( )
@@ -63,15 +63,21 @@ enum SpecificAzureCredentialKind {
6363#[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
6464#[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
6565impl TokenCredential for SpecificAzureCredentialKind {
66- async fn get_token ( & self , scopes : & [ & str ] ) -> azure_core:: Result < AccessToken > {
66+ async fn get_token (
67+ & self ,
68+ scopes : & [ & str ] ,
69+ options : Option < TokenRequestOptions > ,
70+ ) -> azure_core:: Result < AccessToken > {
6771 match self {
6872 #[ cfg( not( target_arch = "wasm32" ) ) ]
69- SpecificAzureCredentialKind :: AzureCli ( credential) => credential. get_token ( scopes) . await ,
73+ SpecificAzureCredentialKind :: AzureCli ( credential) => {
74+ credential. get_token ( scopes, options) . await
75+ }
7076 SpecificAzureCredentialKind :: ManagedIdentity ( credential) => {
71- credential. get_token ( scopes) . await
77+ credential. get_token ( scopes, options ) . await
7278 }
7379 SpecificAzureCredentialKind :: WorkloadIdentity ( credential) => {
74- credential. get_token ( scopes) . await
80+ credential. get_token ( scopes, options ) . await
7581 }
7682 }
7783 }
@@ -133,7 +139,11 @@ impl SpecificAzureCredential {
133139#[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
134140#[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
135141impl TokenCredential for SpecificAzureCredential {
136- async fn get_token ( & self , scopes : & [ & str ] ) -> azure_core:: Result < AccessToken > {
137- self . source . get_token ( scopes) . await
142+ async fn get_token (
143+ & self ,
144+ scopes : & [ & str ] ,
145+ options : Option < TokenRequestOptions > ,
146+ ) -> azure_core:: Result < AccessToken > {
147+ self . source . get_token ( scopes, options) . await
138148 }
139149}
0 commit comments