Error: Missing required parameter [code_verifier] from HTTP module with oAuth 2.0 Request

I am trying to connect Twitter API with HTTP oAuth 2.0 Module.

Authorize URL: https://twitter.com/i/oauth2/authorize
Token URI: https://api.twitter.com/2/oauth2/token

Scope: tweet.write

Client ID & Client Secret

Authorize parameters

response_type=code
code_challenge=challenge
code_challenge_method=plain
redirect_uri=https://www.integromat.com/oauth/cb/twitter2

When I try to connect, I get an error

Missing required parameter [code_verifier]

Looks like, code_verifier is not passed to https://api.twitter.com/2/oauth2/token

How can I solve the issue?

I can get the Authorize Page

But then I get the following error

{
  "message": "The request failed due to failure of a previous request.",
  "code": "SC424",
  "suberrors": [
    {
      "message": "Status Code Error: 400",
      "name": "RuntimeError"
    }
  ],
  "debug": [
    [
      "request",
      "POST",
      "https://api.twitter.com/2/oauth2/token",
      {
        "body": {
          "code": "***",
          "client_id": "-----",
          "grant_type": "authorization_code",
          "redirect_uri": "https://www.integromat.com/oauth/cb/oauth2"
        },
        "headers": {
          "user-agent": "Make/production",
          "authorization": "***",
          "content-type": "application/x-www-form-urlencoded"
        },
        "timeout": 40000,
        "type": "urlencoded"
      }
    ],
    [
      "response",
      400,
      {
        "body": {
          "error": "invalid_request",
          "error_description": "Missing required parameter [code_verifier]."
        },
        "headers": {
        
        }
      }
    ]
  ]
}
1 Like

did you found some solution ?

Nah. Waiting for community response

On the Twitter Github repo, user jgjr mentions:

I have resolved the issue by passing my own code_challenge and setting the code_challenge_method as ‘plain’. I then store the code_challenge and generate another authURL with the same code_challenge before generating the access token. I hope that helps if anyone else is in the same situation.

In the initial call of generateAuthURL() I use code_challenge_method: ‘plain’ and save the code_challenge that I use. Then when the user is redirected back to my platform I call the generateAuthURL() method again with the same saved code_challenge, and then the requestAccessToken() method with the code I have received.

@Mir_Shahriar_Sabuj …Can you please see to the solution provided by samliew , as I have very little knowledge of coding. Please see to it, if you can provide some solution, it will be of great help.