# Unable to get access token (ESI, PHP, Curl)

**URL:** <https://forums.eveonline.com/t/unable-to-get-access-token-esi-php-curl/34461>\
**Category:** Third Party Developers\
**Created:** [October 26, 2017, 9:44pm UTC](https://forums.eveonline.com/t/unable-to-get-access-token-esi-php-curl/34461 "2017-10-26T21:44:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piotr\_Leusten](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/piotr_leusten/32/169358_2.png) [@Piotr\_Leusten](https://forums.eveonline.com/u/Piotr_Leusten)\
**Post date:** [October 26, 2017, 9:44pm UTC](https://forums.eveonline.com/t/unable-to-get-access-token-esi-php-curl/34461/1 "2017-10-26T21:44:05Z")

</div>

Hi, I’m building my first application for Eve that requires Oauth. Writing it in PHP.

I’m able to login and get an authorization code.

But when I try to exchange the authorization code for an access token, I keep getting “invalid client” errors.

I’ve triple-checked the client ID and secret key for the app, which are hardcoded for dev purposes.

Can someone give me a hint as to what I might be doing wrong? Here’s the relevant code:

```
//Get tokens
$authURL = "https://login.eveonline.com/oauth/token";

$authPost = "grant_type=authorization_code&code=".$authCode;

$authHeaders = array(
	'Host: login.eveonline.com',
	'Content-Type: application/x-www-form-urlencoded',
	'Authorization: Basic '.base64_encode($clientID.":".$secretKey)
);	

$ch = curl_init($authURL);

curl_setopt($ch, CURLOPT_HTTPHEADER, $authHeader);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $authPost);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  

$authResponse = json_decode(curl_exec($ch));

curl_close($ch);

```

Thanks!

---

<div class="post-metadata">

**Author:** ![Piotr\_Leusten](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/piotr_leusten/32/169358_2.png) [@Piotr\_Leusten](https://forums.eveonline.com/u/Piotr_Leusten)\
**Post date:** [October 26, 2017, 10:57pm UTC](https://forums.eveonline.com/t/unable-to-get-access-token-esi-php-curl/34461/2 "2017-10-26T22:57:42Z")

</div>

Never mind. “$authHeader” /= “$authHeaders”…

---

<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:** [January 24, 2018, 10:57pm UTC](https://forums.eveonline.com/t/unable-to-get-access-token-esi-php-curl/34461/3 "2018-01-24T22:57:51Z")

</div>

Closed on January 24, 2018, 10:57pm UTC

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