Open andlr opened 8 months ago
Yes, it probably does not need authentication. The spec defines it as:
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
Rather than the usual:
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
The services code gen doesn't currently look at the securityDefinitions
. Instead of using azure_identity::DefaultAzureCredentialBuilder
probably just implement a get_token
that does not do anything. Try copying https://github.com/Azure/azure-sdk-for-rust/pull/1574/files to you project.
azure_svc_imds::Client
can be created either withazure_svc_imds::Client::builder(credential).build()?
orazure_svc_imds::Client:: new(endpoint, credential, scopes, options)
. In both cases, it requires a parameter of typeArc<dyn TokenCredential>
.I've tried to use it with
DefaultAzureCredentialBuilder
like this:And on Azure VM I got this error:
It occurs when request builder tries to get a token here, for host
169.254.169.254
:But the thing is, IMDS doesn't require auth at all. I've removed code above so that request is sent without trying to get a token, and it works without problems.