How to fix AADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code has expired.

Marika Zimante 20 Reputation points
2024-08-01T15:13:11.42+00:00

How to fix AADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code has expired.

Every time I want to download Symbols from Business Central SaaS frist i am getting message "

Acquiring token for authority

. After some time I am getting Error: ADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code has expired. Already tryed to use an Option to login direct with Azure: Sign with device code, what is sucesfull, but still not able to download symbols.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,672 questions
{count} votes

Accepted answer
  1. Chandra Boorla 14,685 Reputation points Microsoft External Staff Moderator
    2024-08-06T16:22:55.5133333+00:00

    Hi @Marika Zimante

    Thanks for the question and using MS Q&A platform.

    I understand that you are trying to download symbols from Business Central SaaS, but you are facing an error during the authentication process. Specifically, you are seeing the error message "AADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code has expired."

    The error indicates that the device code you are using has expired. Device codes are short-lived and if not used within a specific time frame, they become invalid.

    Here are some troubleshooting steps that might help you:

    Expired device code: When you generate a device code, make sure to complete the authentication process promptly. Device codes typically have a validity period of a few minutes.

    Complete Authentication Promptly: Ensure you complete the authentication process within the validity period of the device code.

    Incorrect device code: The device code might be incorrect or malformed, causing the authentication to fail.

    Check System Time: Ensure that your system clock is accurate. Significant time differences between your system clock and the Azure AD server can cause token issues.

    By following these steps and ensuring timely actions, you should be able to resolve the AADSTS70020 error and successfully download symbols from Business Central SaaS.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Jeremy Vyska 5 Reputation points MVP
    2024-09-12T08:24:00.4966667+00:00

    I came across this thread from a search.

    This is a problem related to the Business Central AL extension inside VSCode, not a Azure auth issue.

    What's happening is that the AL Extension is trying to do the "Device Login" flow and pops a Notification for the user to copy the Device Login Code, then authorize the app.

    But, if you've hidden that Notification, it appears to just hang, eventually timing out. To resolve this issue, in the Notification 🔔 in the very bottom right corner of VSC, "Turn On" the device login notifications again.

    1 person found this answer helpful.
    0 comments No comments

  2. Amira Bedhiafi 34,731 Reputation points Volunteer Moderator
    2024-08-01T17:28:47.1566667+00:00

    Based on this old thread :

    The error is caused by using a tenant specific /devicecode endpoint and trying to authenticate as a personal account. You need to use one that targets the common or consumers pseudo tenant. I.e. Instead of https://login.microsoftonline.com/<TENANT ID>/oauth2/v2.0/devicecode Use https://login.microsoftonline.com/common/oauth2/v2.0/devicecode

    also this thread :

    When you try to request a new access token, use this scope [https://graph.microsoft.com/.default](https://graph.microsoft.com/.default)

    All Client Credentials requests on the v2 endpoint must include scope={resource}/.default where {resource} is the API which the app intends to call.

    References: c# - AADSTS70011: The provided value for the input parameter 'scope' is not valid - Stack Overflow, Application permission 'scopes' · Issue #36432 · MicrosoftDocs/azure-docs · GitHub and Cannot get access token for scope https://graph.microsoft.com/User.ReadWrite.All · Issue #449 · AzureAD/microsoft-authentication-library-for-dotnet · GitHub


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.