AnsweredAssumed Answered

error code 600 when trying to get access token

Question asked by Adrian Voicu on Sep 3, 2018
Latest reply on Sep 3, 2018 by Sanford Whiteman

Hello community,

 

I have a small problem related to retrieving the access token using REST API. What is weird is that although everything works fine in the local environment, the story changes when using the same code on the testing environment. In WordPress I have this small piece of code:

$resourceUrl = $this->identityUrl.'oauth/token?grant_type=client_credentials&client_id=' . $this->clientId . '&client_secret=' . $this->clientSecret;
        $args = array(
            'headers' => array(
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
            )
        );
$response = wp_remote_get($resourceUrl, $args);

 

The problem here is that although on local server everything works ok, and I can retrieve the authentication token, on the testing server, this does not work, the resulting decoded json of the response being this:

 

["headers"]=>
  object(Requests_Utility_CaseInsensitiveDictionary)#1158 (1) {
    ["data":protected]=>
    array(4) {
      ["server"]=>
      string(5) "nginx"
      ["date"]=>
      string(29) "Mon, 03 Sep 2018 09:18:57 GMT"
      ["content-type"]=>
      string(30) "application/json;charset=UTF-8"
      ["content-length"]=>
      string(3) "113"
    }
  }
  ["body"]=>
  string(113) "{"requestId":"e097#1659eba5b83","success":false,"errors":[{"code":"600","message":"Access token not specified"}]}"
  ["response"]=>
  array(2) {
    ["code"]=>
    int(200)
    ["message"]=>
    string(2) "OK"
  }
  ["cookies"]=>
  array(0) {
  }
  ["filename"]=>
  NULL
  ["http_response"]=>
  object(WP_HTTP_Requests_Response)#1167 (5) {
    ["response":protected]=>
    object(Requests_Response)#1155 (10) {
      ["body"]=>
      string(113) "{"requestId":"e097#1659eba5b83","success":false,"errors":[{"code":"600","message":"Access token not specified"}]}"
      ["raw"]=>
      string(270) "HTTP/1.1 200 OK
Server: nginx
Date: Mon, 03 Sep 2018 09:18:57 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 113
Connection: close

 

What I find weird is that it says that no access token was specified, even though that is exactly what I required to receive. Is there something I'm missing here? Thank you.

Outcomes