Instagram oauth api gives { “code”: 400, “error_type”: “OAuthException”, “error_message”: “No matching code found.” }

前端 未结 7 1491
孤独总比滥情好
孤独总比滥情好 2020-12-25 11:52

I am working on an application that integrates with Instagram API to access the user information. I successfully fetch the Access Token using the authorize url but unable to

相关标签:
7条回答
  • 2020-12-25 12:20

    I got same error. It seems that instagram's spam system disable user's access to any non-official application. Just change user's password. In my case it was help. Also try create another application.

    UPD

    From my answer to another question

    It looks like users get more than one code, and you see first code, but need second. Try relogin users, if you gets error. User will not see instagram page with confirm button, just redirections.

    Possible algorithm of error:

    1. User click auth link.
    2. Get first code.
    3. User click auth link (twice, redirection problem, public auth system, etc.)
    4. Get another code (even on the same client_id, redirect_uri).
    5. You get first code.
    6. But first code already doesn't exists.
    
    0 讨论(0)
  • 2020-12-25 12:24

    I will mention what worked for me.

    Step 1. Generate a new client secret from you panel.

    Step 2. Follow the step 1 mentioned here to obtain the code again.

    Step 3. Send the request again with the changed parameters.

    Make sure you are logged in the browser when you send the request. You will get the required response.

    0 讨论(0)
  • 2020-12-25 12:27

    The problem is here that need redirect url set as http://localhost/signin-instagram

    signin-instagram part is very important So go to Instagram.com/developer ->Manage Client-> Security -> Valid redirect URIs set with that end http:/../signin-instagram

    0 讨论(0)
  • 2020-12-25 12:30

    I found that using either form-data or application/x-www-form-urlencoded works fine. The most important is the code you get from redirect uri is only used by one request. It means you could request the access token once for the code. If the you request more than one time with same code, you'll get the error like this:

    {
        code: 400,
        error_type: "OAuthException",
        error_message: "Matching code was not found or was already used."
    }
    

    Wish you all the best ;)

    0 讨论(0)
  • 2020-12-25 12:34

    Try to urlEncode the redirect_uri param to

    http%3A%2F%2Flocalhost
    

    And your code param contains the "." character which might be a error.

    code=1351860224.4827556.5dc92c4d15ea4a4ea1b0d33eaf0eef19
    

    might caused the problem

    "error_message": "No matching code found."
    

    "5dc92c4d15ea4a4ea1b0d33eaf0eef19" seems to be the correct code

    0 讨论(0)
  • 2020-12-25 12:37

    For me unchecking Disable implicit OAuth in instagram developer -> manage clients fixed the issue

    0 讨论(0)
提交回复
热议问题