How to fix "AADSTS70000: The provided value for the 'code' parameter is not valid. The code has expired."

CMS Staging 0 Reputation points
2024-02-19T10:19:27.7966667+00:00

We've registered an APP on Azure which we're using for reading and writing files on oneDrive. We're using authentication code to receive "access_token" however I get error when I request for "access_token" with authentication code. Error: "AADSTS70000: The provided value for the 'code' parameter is not valid. The code has expired." The code is getting used after few seconds of creation, so it's unlikely that it's expired.

OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,075 questions
Microsoft Entra
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,431 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 29,741 Reputation points Microsoft Employee
    2024-02-19T12:03:24.7233333+00:00

    Hi @CMS Staging

    Thanks for reaching out.

    As per error it seems you are trying to get access token using Authorization Code Flow. Authorization code flow has 2 parts:

    Request an authorization code by passing the required parameters.

    Second, to request for access token by passing valid authorized code along with other parameters.

    You are getting the error AADSTS70000: The provided value for the 'code' parameter is not valid. The code has expired because Authorization codes are short lived, typically expiring after about 10 minutes.

    If you want to get the access token, then you need to provide valid authorize code. In this scenario it would require requesting authorize code again.

    Hope this will help.

    Thanks,

    Shweta


    Please remember to "Accept Answer" if answer helped you.


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.