cancel
Showing results for 
Search instead for 
Did you mean: 

REST API - new integration - "400 Bad Request" response with missing body - how to troubleshoout?

REST API - new integration - "400 Bad Request" response with missing body - how to troubleshoout?

Hello all

 

In the callback processing code according to "OAuth-based authentication" - "Get a request token" ( https://devdocs.magento.com/guides/v2.2/get-started/authentication/gs-authentication-oauth.html#pre-... ), we receive a scarce response that misses any details (response body) - here is the output of var_dump($oauthClient->debugInfo);

 

Error Message: Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)
Details: object(OAuthException)#2 (9) {
["message":protected]=>string(73) "Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)"
["string":"Exception":private]=>string(0) ""
["code":protected]=>int(400)
["file":protected]=>string(89) "/var/www/clentSite.com/magento/auth/callback.php"
["line":protected]=>int(36)
["trace":"Exception":private]=>array(1) {
[0]=>array(6) {
["file"]=>string(89) "/var/www/clientSite.com/magento/auth/callback.php"
["line"]=>int(36)
["function"]=>string(15) "getRequestToken"
["class"]=>string(5) "OAuth"
["type"]=>string(2) "->"
["args"]=>array(3) {
[0]=>string(51) "https://www.XXX.org/oauth/token/request"
[1]=>NULL
[2]=>string(4) "POST"
}
}
}
["previous":"Exception":private]=>NULL
["lastResponse"]=>NULL
["debugInfo"]=>array(3) {
["sbs"]=>string(262) "POST&https://www.XXX.org/oauth/token/request&oauth_consumer_key=wmcv20wo6iqqi6ir4377u2mfny7p988r&oauth_nonce=12043217595c90acbbd481f7.33982001&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1552985275&oauth_version=1.0"
["headers_sent"]=>string(261) "Authorization: OAuth oauth_consumer_key="wmcv20wo6iqqi6ir4377u2mfny7p988r",oauth_signature_method="HMAC-SHA1",oauth_nonce="12043217595c90acbbd481f7.33982001",oauth_timestamp="1552985275",oauth_version="1.0",oauth_signature="Mmz%2BhxEhvg21HDJ%2FVf1%2BhgIKZDk%3D""
["headers_recv"]=>string(380) "HTTP/1.1 400 Bad Request
Date: Tue, 19 Mar 2019 08:47:56 GMT
Connection: close
Set-Cookie: __cfduid=d9c479c8905746675daef05c7a008256c1552985276; expires=Wed, 18-Mar-20 08:47:56 GMT; path=/; domain=.XXX.org; HttpOnly
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4b9e2f36bcd1cf36-IAD"
}
}
It was expected that the response contained appropriate body with details like
 
  ["body_recv"]=>
  string(211) "oauth_problem=oauth_consumer_key+is+a+required+field%2C+oauth_signature+is+a+required+field%2C+oauth_signature_method+is+a+required+field%2C+oauth_nonce+is+a+required+field%2C+oauth_timestamp+is+a+required+field"
but it did not in the case above.
 
Is there a way to troubleshoot this "400 Bad Request" other than reading the body (that is missing in this case)  - logs observation (where to look into), HTTP server / Magento 2 configuration, other?