High severityauthentication
Power BI Error:
AADSTS70018
What does this error mean?
The user code entered at microsoft.com/devicelogin is invalid, mistyped, or already expired before approval.
Common causes
- 1User mistyped the user_code shown by the CLI/headless client on https://microsoft.com/devicelogin
- 2The user_code expired before the user completed sign-in (default lifetime ~15 minutes)
- 3User pasted/entered an old code from a previous device code request instead of the latest one
- 4Headless tooling (Power BI Gateway setup, az login --use-device-code, Databricks CLI, Fabric CLI) re-issued a new code while the user was still entering the previous one
- 5Conditional Access or MFA prompt was cancelled mid-flow, leaving authorization not approved
How to fix it
- 1Restart the device code flow in your tool (e.g. `az login --use-device-code`, Power BI on-prem gateway sign-in, Databricks CLI auth) to get a fresh user_code
- 2Open https://microsoft.com/devicelogin in a browser and type the code exactly as shown — codes are case-sensitive and must be entered within ~15 minutes
- 3Complete the full sign-in including any MFA / Conditional Access prompts; do not close the tab until you see 'You have signed in'
- 4If you keep mistyping, copy the code from the terminal instead of reading it; for scripted scenarios switch to a non-interactive flow (client credentials or managed identity) so no user_code is needed
- 5If the error persists for a service/automation account, verify the app registration has 'Allow public client flows' enabled in Entra ID → App registrations → Authentication