Skip to main content

Fixed: "You don't have access to this" (Error Code 53003) When You Sign In to the Azure CLI with a Device Code

· 17 min read
Jagdish Kumawat
Founder @ Dewiride

I signed a second account in to the Azure CLI with az login --use-device-code. The sign-in page took the code and the password, then said "You don't have access to this", with error code 53003 behind its More details link, while the terminal just kept waiting. My tenant's Conditional Access blocks the device code flow, and the same az login without --use-device-code, which signs in through the browser, worked.

What I Was Doing​

I was adding a second account to the Azure CLI on my Mac: a new test user in my Microsoft Entra tenant, with no Azure subscription. My own account was already signed in, and I wanted to keep it that way. The Azure CLI keeps its sign-in in a configuration folder, ~/.azure by default, and Microsoft's tips for the Azure CLI describe the environment variable that moves it: with AZURE_CONFIG_DIR set, Azure CLI commands in that script save the configuration and token cache to the configured location instead of the default ~/.azure folder. How to Sign In to Two Accounts at Once in the Azure CLI shows that setup on its own.

On 2026-12-03 at 08:11 UTC, I signed the test user in with a device code, into a folder of its own, ~/.azure-test-manager:

Terminal
AZURE_CONFIG_DIR=~/.azure-test-manager az login --tenant contoso.onmicrosoft.com --allow-no-subscriptions --use-device-code
  • AZURE_CONFIG_DIR=~/.azure-test-manager sets the configuration folder for this one command, so my own sign-in in ~/.azure stays as it is.
  • --tenant contoso.onmicrosoft.com is the tenant's domain. Microsoft's guide to signing in says the value can either be a .onmicrosoft.com domain or the Azure object ID for the tenant.
  • --allow-no-subscriptions lets an account without an Azure subscription sign in. The az login reference describes it as Support accessing tenants without subscriptions.
  • --use-device-code asks for the device code flow. Instead of opening a browser, the Azure CLI prints a web address and a code, and you sign in on that page.

The Azure CLI answered with the page and the code:

Output
To sign in, use a web browser to open the page https://login.microsoft.com/device and enter the code HMFLQEZPM to authenticate.

I opened the page, typed the code, and signed in with the test user's name and password.

What I Expected​

The page would confirm the sign-in, and the Azure CLI would finish signing the test user in, in its own folder.

What I Got​

The page took the code and the password, and then showed this instead of a confirmation:

Sign-in page
You don't have access to this
Your sign-in was successful but does not meet the criteria to access this resource. For example, you might be signing in from a browser, app, location, or an authentication flow that is restricted by your admin.

The terminal printed nothing. It didn't fail and it didn't finish: it just waited. I pressed Ctrl+C to stop it.

Later that day, with the test user already signed in through the browser (the fix below), I ran the device code sign-in once more, at 12:12 UTC, in a new configuration folder. I wanted to read the page's More details link and to see what the terminal does when it's left alone. The Azure CLI printed a new code, HH7P8DD99, and the page asked for it:

Microsoft's Enter code to allow access page with the code HH7P8DD99 typed in, under the warning Do not enter codes from sources you don't trust.

The browser still had the test user signed in, so after Next it only asked me to pick the account. Then came the same page as before:

Microsoft sign-in page for test.manager@contoso.onmicrosoft.com that says You don't have access to this, because the sign-in doesn't meet the criteria to access the resource, for example an authentication flow restricted by the admin, with a More details link and an OK button.

More details opened the troubleshooting details:

Troubleshooting details pane showing Error Code 53003, App name Microsoft Azure CLI, Device platform macOS and Device state Unregistered, with the request and correlation IDs masked and a Copy info to clipboard link.

Error code 53003, for the app Microsoft Azure CLI. The terminal, again, printed nothing. This time I left it running, and at 12:27 UTC, 15 minutes after the code appeared, it gave up:

Output (IDs masked)
To sign in, use a web browser to open the page https://login.microsoft.com/device and enter the code HH7P8DD99 to authenticate.
AADSTS70016: OAuth 2.0 device flow error. Authorization is pending. Continue polling. Trace ID: 00000000-0000-0000-0000-000000000000 Correlation ID: 00000000-0000-0000-0000-000000000000 Timestamp: 2026-12-03 12:27:00Z
Run the command below to authenticate interactively; additional arguments may be added as needed:
az logout
az login

macOS-style terminal window showing az login with --use-device-code printing the code HH7P8DD99, then AADSTS70016 Authorization is pending, and the suggestion to run az logout and az login.

The terminal never mentioned 53003. Its last word was that the authorization was still pending.

What I Checked​

What the page said. The page itself said the sign-in "was successful but does not meet the criteria to access this resource", and among the possible reasons it listed "an authentication flow that is restricted by your admin". A device code sign-in is such a flow: Conditional Access: Authentication flows says Conditional Access lets you control certain authentication flows, starting with the device code flow.

What error code 53003 means. Microsoft's authentication and authorization error codes list AADSTS53003 as BlockedByConditionalAccess - Access has been blocked by Conditional Access policies. The access policy does not allow token issuance. Conditional Access is, in Microsoft's words, a Microsoft Entra feature that allows organizations to enforce security requirements when accessing resources. What is Conditional Access? puts it more simply: Conditional Access policies at their simplest are if-then statements: if a user wants to access a resource, then they must complete an action. It also says: Conditional Access policies are enforced after first-factor authentication is completed. That is why the password worked and the sign-in was still refused.

Which policy blocked it. The page doesn't name the policy, but the tenant's sign-in log does. In the Microsoft Entra admin center, I opened Users, selected the test user, and opened its Sign-in logs. Both device code sign-ins were there, at 08:11 and 12:13 UTC, each with the status Failure and the sign-in error code 53003. Selecting the one at 12:13 UTC opened its details, and the Basic info tab showed the same error code with its failure reason:

Basic info tab of the failed sign-in in the Microsoft Entra sign-in log, showing Status Failure, Sign-in error code 53003 and the failure reason Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.

The Conditional Access tab listed several policies, each with a result for this sign-in. The others said Not Applied or Success. To show only the one that matters here, I typed device code into the tab's search box:

Conditional Access tab of the same sign-in, searched for device code, showing the policy Microsoft-managed: Block device code flow with the grant control Block and the result Failure.

Microsoft-managed: Block device code flow, with the grant control Block and the result Failure.

What that policy does. Microsoft-managed Conditional Access policies are policies Microsoft creates in eligible tenants, and their names start with Microsoft-managed:. About this one, the page says: This policy blocks device code flow, where a user initiates authentication on one device, completes on another, and their token is sent back to the original device. It also gives the reason: Device code flow is rarely used by customers, but is frequently used by attackers.

Why tenants block device codes. Conditional Access: Authentication flows calls the device code flow a high-risk authentication method that can be part of a phishing attack or used to access corporate resources on unmanaged devices, and adds: Microsoft recommends blocking device code flow wherever possible. Microsoft's guidance on restricting device code flow describes the phishing: An attacker can start the flow, send a user a code, and ask the user to enter that code on a legitimate Microsoft sign-in page. That's why the code page warns "Do not enter codes from sources you don't trust."

Why the terminal said nothing. Microsoft's description of the device code flow explains the waiting. After it shows the code, the client keeps asking for a token: While the user is authenticating at the verification_uri, the client should be polling the /token endpoint for the requested token using the device_code. Until someone finishes signing in, the answer is authorization_pending, and the client asks again. From the moment the request is sent, the user has 15 minutes to sign in. The blocked sign-in never finished, so the Azure CLI heard "pending" for 15 minutes. The error code reference describes the AADSTS70016 it printed at the end as AuthorizationPending - OAuth 2.0 device flow error. Authorization is pending.

Why It Happens​

az login --use-device-code signs in with the device code flow. My tenant has the Microsoft-managed Conditional Access policy Block device code flow turned on. So Microsoft Entra ID checks the password and then, because of the policy's Block control, refuses to issue a token. The page reports that as error 53003. The Azure CLI never learns why: from its side, the sign-in just never finishes, so it waits until the code expires.

The Fix​

Sign in without --use-device-code. On macOS and Linux, az login then uses the browser: If Azure CLI can open your default browser, it initiates authorization code flow and opens the default browser to load an Azure sign-in page. On Windows, it uses Web Account Manager (WAM) by default, which Microsoft describes as a Windows 10+ component that acts as an authentication broker. Neither is the device code flow, and Microsoft's guidance for organizations that block it points the same way: Prefer browser-based or brokered sign-in for users. I signed in on macOS, with the browser.

Here is the same command as before, without --use-device-code:

Terminal
AZURE_CONFIG_DIR=~/.azure-test-manager az login --tenant contoso.onmicrosoft.com --allow-no-subscriptions

In PowerShell, the first line sets AZURE_CONFIG_DIR for the rest of the window, and the last line removes it again, so later az commands use your own sign-in. If you don't use a configuration folder of your own, leave out the AZURE_CONFIG_DIR part.

The browser opens Microsoft's sign-in page: sign in as the account you're adding. My test user still had its temporary password, so this first browser sign-in asked for a new one; How to Sign In to Microsoft 365 for the First Time with a Temporary Password shows those screens.

The policy itself stays as it is. Whether a tenant allows the device code flow is for its administrators to decide, and Microsoft's advice to them is to block it wherever possible.

After the Fix​

The browser sign-in at 08:16 UTC went through, and the browser landed on the Azure CLI documentation:

Microsoft Learn's Azure Command-Line Interface (CLI) documentation page, with Azure CLI 2.93.0 in its version box, which the browser opened after the sign-in.

The terminal listed what the test user can use, and asked which one to keep:

Output (IDs masked)
A web browser has been opened at https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.

Retrieving subscriptions for the selection...

[Tenant and subscription selection]

No Subscription name Subscription ID Tenant
----- ------------------------- ------------------------------------ ------------------------------------
[1] * N/A(tenant level account) 11111111-1111-1111-1111-111111111111 11111111-1111-1111-1111-111111111111

The default is marked with an *; the default tenant is '11111111-1111-1111-1111-111111111111' and subscription is 'N/A(tenant level account)' (11111111-1111-1111-1111-111111111111).

Select a subscription and tenant (Type a number or Enter for no changes):

macOS-style terminal window showing az login without --use-device-code opening a web browser, then listing one tenant-level account, N/A(tenant level account), and asking to select a subscription and tenant.

N/A(tenant level account) is a sign-in to the tenant without a subscription, the kind --allow-no-subscriptions allows. It's the only choice and already the default, marked with *, so press Enter to keep it.

The test user's sign-in log shows this sign-in at 08:16 UTC with the status Success, and Success under Conditional Access too.

Common Mistakes​

MistakeWhat happensDo this instead
Waiting for the terminal to explain the errorIt waits until the code expires after 15 minutes, then only says the authorization is pendingRead More details on the page, or the sign-in log
Trying the device code sign-in againThe same page and the same error code 53003Sign in without --use-device-code
Entering a device code that someone else sent youThat is the phishing pattern this policy exists to stopOnly enter a code from a sign-in you started yourself

Troubleshooting​

SymptomLikely causeFix
"You don't have access to this" right after the device code and the passwordConditional Access blocks the device code flowaz login without --use-device-code
More details shows Error Code 53003A Conditional Access policy blocked the sign-inOpen the sign-in in the sign-in log and read its Conditional Access tab
The terminal prints AADSTS70016 and "Authorization is pending"The code expired before a sign-in finishedSign in again, with the browser if the device code flow is blocked
The browser sign-in asks for a new passwordThe account still has its temporary passwordSet a new password, and the sign-in finishes

FAQ​

Why doesn't the Azure CLI print error 53003?​

The block happens on the sign-in page, in the browser. The Azure CLI only asks for a token, again and again, and hears that the authorization is pending until the code expires. Then it prints AADSTS70016. The error code 53003 is on the page, under More details, and in the sign-in log.

Does the policy block the browser sign-in too?​

No. It blocks the device code flow, and the browser sign-in uses the authorization code flow. In the same tenant, my browser sign-in succeeded, with Success under Conditional Access in the sign-in log.

Why does my tenant have this policy?​

Microsoft creates its managed policies in eligible tenants itself: Administrators don't need to manually create these policies. Each one starts in report-only mode, and Microsoft enables these policies no less than 30 days after they're introduced in your tenant if they're left in the Report-only state. So the block can be on without anyone in your organization having created it.

What if the machine has no browser?​

The az login reference says the Azure CLI falls back to the device code flow then: Azure CLI will also use this if it can't launch a browser, e.g. in remote SSH or Cloud Shell. It's the same flow, so the same policy applies to it. Whether a case like that gets an exception is for your administrator to decide. For scripts and pipelines, Microsoft's guidance is: For automation, prefer managed identities or workload identity federation.

Who can read the sign-in log?​

Microsoft's steps for reading it start with signing in to the Microsoft Entra admin center as at least a Reports Reader. If you can't open it, use Copy info to clipboard under More details and send that to your administrator, as the pane suggests: "If you contact your administrator, send this info to them."

Conclusion​

If az login --use-device-code ends on "You don't have access to this" with error code 53003, a Conditional Access policy in your tenant blocks the device code flow. In mine, it was Microsoft-managed: Block device code flow. The terminal won't tell you: it waits until the code expires. Sign in through the browser instead, with the same az login minus --use-device-code, and leave the policy to your administrator.

Additional Resources​