'Microsoft Azure CLI is giving me an access token without a refresh token. How do I get an access token that has a refresh token?

I'm trying to get AKS credentials set up for a gitlab-runner environment. I can get a basic kubeconfig with az aks get-credentials -n mythingname -g myresourcegroup -f kubeconfig but the resulting kubeconfig doesn't have access or refresh tokens.

Using the Azure CLI command az account get-access-token gets me an access token, but it doesn't come with a refresh token.

I've looked around and I either can't find an answer or can't find the right google search terms to find the answer. Microsoft's own documentation for Azure CLI is unenlightening on this topic.



Solution 1:[1]

Please note that using az account get-access-token command, you won't be able to retrieve refresh token.

With that command you can get access token only like below:

enter image description here

Azure CLI performs the token refreshing automatically. So, it won't generate refresh token separately. Please check the below GitHub blog:

https://github.com/Azure/azure-cli/issues/6234#issuecomment-387848841

If you particularly want to retrieve refresh token, try registering an Azure AD App and use Postman API to retrieve refresh token and access token like below:

enter image description here

For more information, please refer below links:

Add login refresh command · Issue #6234 · Azure/azure-cli · GitHub

Microsoft identity platform refresh tokens - Microsoft identity platform | Microsoft Docs

Azure registered app error: The user or administrator has not consented to use the application with ID - Stack Overflow

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SrideviMachavarapu-MT