Closed lcrownover closed 6 months ago
get_token
is exposed via the TokenCredential trait, which the azure-identity credential providers implement.
Import azure_core::auth::TokenCredential
and you'll have access to get_token.
That's interesting. The following code works:
let credential = DefaultAzureCredential::default();
let token = credential
.get_token(&["https://management.azure.com/.default"])
.await?;
println!("token: {:?}", token.token.secret());
But after creating the credential
, rust-analyzer doesn't seem to know about any of that functionality:
"get_token" listed in completions is just sourced from existing text in the buffer.
Same with VS Code:
I don't have buffer text completion configured in VS Code so there's no completions available at all.
I don't know much about how rust-analyzer works, but can you reproduce this?
I'm not familiar with using that portion of VS Code + rust-analyzer. With VS Code + rust-analyzer, I can confirm it is able to find the implementation using this example:
use azure_identity::DefaultAzureCredential;
use azure_core::auth::TokenCredential;
fn main() {
let credential = DefaultAzureCredential::default();
let _ = credential.get_token(&[".default"]);
}
As such, addressing issues in rust-analyzer+vscode is out of scope for the Azure SDK for Rust.
Fair enough, if your environment shows correct autocompletions then I suspect something is off on my end.
Thanks for the help!
I'm trying to do something very simple: Use use the Azure CLI to print out an access token.
In trying to get something going, I'm following the official example on the azure_identity docs on crates.io, it shows:
credential
is an instance ofDefaultAzureCredential
, which does not have a *public*.get_token()
method. Usingdefault()
, the resulting object looks like:So I then look at the README.md for the azure_identity package in this repository and it instead shows:
The only
create_credential()
method I see is in the token_credentials::specific_azure_credential file. This example doesn't work either.So what is the correct way to get a token? There are plenty of
get_token()
andget_access_token()
methods all over, but they're all private.