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

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!

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

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