An error has occurred

Hello there,

I have started using (trying to) the new API, and I am a bit confused as I am getting an error which is not an error. I am running the following code in my machine:

$bodyData = array(
     "grant_type" => "authorization_code",
     "code" => $code);

 $headerData = array(
    "Authorization:Basic " . base64_encode(clientID.":".secretKey),

 $curl = curl_init();

 $url = '';

 $certificate = "C:\wamp64\certs\cacert.pem";
 curl_setopt($curl, CURLOPT_CAINFO, $certificate);
 curl_setopt($curl, CURLOPT_CAPATH, $certificate);

 curl_setopt($curl, CURLOPT_URL, $url);
 curl_setopt($curl, CURLOPT_POST, true);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($bodyData));
 curl_setopt($curl, CURLOPT_HTTPHEADER, $headerData);

 $response = curl_exec($curl);
 if( $response === false){
     echo 'Curl error: ' . curl_error($curl);
     echo $response;

This was supposed to complete the step two in the authorization but, although the curl command is not generating any error, the response I am getting is:

{ "Message" : "An error has occurred." }

I am not sure what I am doing wrong and unfortunately Google has not been of great help until now.

I tried to run the same from the command line as

curl -XPOST -H "Content-Type:application/json" -H "Authorization:Basic ZWRlODdiOWIzZGMyNGR...SE1mREpYTFlDNWVjRkptSGQwMFlzWUc4MXpETU9vcDZIYmZYeg==" -d '{"grant_type":"authorization_code", "code":"DKVHTD6MQXt-t9YNe4SVD8ATe...mwl0NBVo35uImZG9IxbHhhjda"}'

and got exactly the same response.

Any hint would be appreciated.

Thanks a lot!


See the docs on how to make these requests:

My first guess is you’re using JSON, when it should be application/x-www-form-urlencoded.

1 Like

That solved the issue; I was looking at old documentation. That has brought another problem

{"error":"invalid_grant","error_description":"Grant type is not supported."}

but I hope to get it done reading the correct docs.

Thanks a lot!


@Blacksmoke16, sorry to bother you. I was not able to find any solution re the second error. Not really sure which grant is the one giving the error.

Can you share your latest code/request?


Well, not quite, but I think that actually shows the problem. Carefully read thru and make sure you’re following the steps. Notice that the URLs are different than what you’re using. I.e. you want to use /v2/oauth/authorize/ and /v2/oauth/token.

That v2 slipped through the cracks in the first call. Thanks for that.

However, /v2/oauth/token is the one to transform the code I get into a token.

As I understood it, first I have to call /v2/oauth/authorize and when I get the code, then I use this code to pass it to /v2/oauth/token together with the secret key, client ID, etc, … as in the code I shared in the first post.

That is what I understood from the page you sent me, which I have almost memorized :smiley:

First I call

and get


and I use the code to call /v2/oauth/token, right?

Yes, you use that code to get a token. Starting on step 4 on that guide ^.

Hey @Gimhae_Kim, are you aware of and the capabilities of the API as well how to use it?

@Rtg_Quack I was indeed. Thanks.

It was me forgetting how to do PHP no more.

Thank you both!


If you use PHP to connect to ESI I might suggest to use a robust OAUTH2 implementation like Evelabs\OAuth2
I use it in my own project, see in particular method eveSsoLogin() in

Hope it helps :slight_smile:

1 Like

There seem to 5 or six folks on the planet who can make ESI work. So it’s a good thing they broke my spreadsheets to those 5 dudes can do the exact same thing they were dong with CREST, which was mostly usable by the average person.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.