Help needed (PHP / request / access token etc. (SOLVED)

,

I created a login button on my website to requests an authenication code from the EVE SSO.
After I received this authentication code I need to send a POST request, for an access token.
Does anyone have an example for me of how I can do this with PHP?

There’s tons of examples. What exactly is your issue?

Hi, thank you for your reply. I will try to explain more…

I followed the information on this page:
https://docs.esi.evetech.net/docs/sso/web_based_sso_flow.html

I managed to handle the steps 1 to 4 on that page, so now my own login page (PHP-file) receives an authentication code with a state that I can further process to request an access token from the EVE SSO. All is good here.
Next I need to send a POST request so I can receive an access token. (Step 5 on the linked page.) I have a hard time translating the given information into working PHP-code. That is why I’m asking if anybody here has an example for me.

I tried this:

$the_request_url        = "https://login.eveonline.com/v2/oauth/token";
$the_request_postfields = array(	'grant_type'    => 'authorization_code',
									'code'          => $received_code );
$the_request_headers    = array(	'Authorization' => 'Basic ' . base64_encode( $EVE_Application_ClientID . ":" . $EVE_Application_SecretKey),
									'Content-Type'  => 'application/x-www-form-urlencoded',
									'Host'          => 'login.eveonline.com' );

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $the_request_url);
curl_setopt($h_curl, CURLOPT_POST, 1);
curl_setopt($h_curl, CURLOPT_POSTFIELDS, http_build_query($the_request_postfields));
curl_setopt($h_curl, CURLOPT_HTTPHEADER, $the_request_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$resp = curl_exec($ch);

if($e = curl_error($ch)) {
	echo $e;
}
else {
	var_dump($resp);
}

curl_close($ch);

The curl_error() function did not respond with an error and the $resp variable is empty.

A curl_getinfo() after the curl_exec() function returned [http_code] => 405.
This looks like a hint. Any help is appreciated. :slight_smile:

I found a video with a good example. Thank you @pengo1998. :+1:t2:

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