# Problem with eve ESI "invalid\_client"

**URL:** <https://forums.eveonline.com/t/problem-with-eve-esi-invalid-client/127045>\
**Category:** Third Party Developers\
**Created:** [December 14, 2018, 9:18pm UTC](https://forums.eveonline.com/t/problem-with-eve-esi-invalid-client/127045 "2018-12-14T21:18:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghal\_Mharaz](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/ghal_mharaz/32/111247_2.png) [@Ghal\_Mharaz](https://forums.eveonline.com/u/Ghal_Mharaz)\
**Post date:** [December 14, 2018, 9:18pm UTC](https://forums.eveonline.com/t/problem-with-eve-esi-invalid-client/127045/1 "2018-12-14T21:18:21Z")

</div>

Hi all.

I started to develop a small web based (php) application using the ESI API. Here is my code right now.

```
<?php
    $authcode = base64_encode("{CLIENT_ID}:{SECRET_KEY}");
    $data = array("grant_type" => "authorization_code", "code" => $_GET["code"]);
    $data_string = json_encode($data);
	
    $ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "https://login.eveonline.com/v2/oauth/token");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
	curl_setopt($ch, CURLOPT_HEADER, array("Content-Type:application/json", "Authorization:Basic " . $authcode)); 

    $result = curl_exec($ch);
	
	if (curl_error($ch))
	{
		$error_msg = curl_error($ch);
		print_r($error_msg);
	}
	curl_close($ch);
	
	print_r($result);
?> 

```

And this is my output…

HTTP/1.1 401 Unauthorized Cache-Control: no-cache Pragma: no-cache Content-Length: 87 Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.5 Date: Fri, 14 Dec 2018 21:11:59 GMT {“error”:“invalid\_client”,“error\_description”:“Missing or invalid client credentials.”}

Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![Ghal\_Mharaz](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/ghal_mharaz/32/111247_2.png) [@Ghal\_Mharaz](https://forums.eveonline.com/u/Ghal_Mharaz)\
**Post date:** [December 15, 2018, 10:51am UTC](https://forums.eveonline.com/t/problem-with-eve-esi-invalid-client/127045/2 "2018-12-15T10:51:08Z")

</div>

I solved it myself with google help:

> $headerData = array(  
> “Authorization:Basic " . base64\_encode(”{CLIENT\_ID}:{SECRET\_KEY}");  
> , “Content-Type:application/json”  
> , “Host:login.eveonline.com”  
> );
> 
> //Request Body payload  
> $bodyData = array(  
> “grant\_type” =\> “authorization\_code”  
> , “code” =\> $\_GET[“code”]  
> );
> 
> //Curl exec  
> $ch = curl\_init();  
> curl\_setopt($ch, CURLOPT\_URL,“[https://login.eveonline.com/v2/oauth/token](https://login.eveonline.com/v2/oauth/token)”);  
> curl\_setopt($ch, CURLOPT\_POST, 1);  
> curl\_setopt($ch, CURLOPT\_HTTPHEADER, $headerData);  
> curl\_setopt($ch, CURLOPT\_POSTFIELDS, json\_encode($bodyData));  
> curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);  
> $result = curl\_exec($ch);  
> curl\_close($ch);

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [March 15, 2019, 10:51am UTC](https://forums.eveonline.com/t/problem-with-eve-esi-invalid-client/127045/3 "2019-03-15T10:51:21Z")

</div>

Closed on March 15, 2019, 10:51am UTC

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