Trying to get an oauth2 token for Azure Key Vault, following the tutorial below.
https://docs.microsoft.com/en-us/azure/key-vault/general/tutorial-net-windows-virtual-machine
Within Azure I am getting the oauth2 token endpoint and making the call to get the token, but getting a response "You must sign into your account". Is the token endpoint supposed to be different? if so where is that found? If I am using the correct endpoint, then how to solve this because the whole purpose of using Key Vault is so that you don't have to store your credentials locally
static string GetToken()
{
WebRequest request = WebRequest.Create("https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token");
request.Headers.Add("Metadata", "true");
WebResponse response = request.GetResponse();
return ParseWebResponse(response, "access_token");
}
WebRequest.Create("http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net")
when we want to get the token of key vault with azure VM. Why do you useWebRequest.Create("https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token")
? – Hury Shen