I
I
Ilya Oblomov2019-02-26 21:42:55
PHP
Ilya Oblomov, 2019-02-26 21:42:55

How to set up SSO authorization on the site?

Good day!
I play EVE online and I want to make one of the sites the possibility of authorization via SSO.
This process is in the article:
https://eveonline-third-party-documentation.readth...
I managed to create an application and make a link that will redirect the user to authorization, and then return him to my site with a unique identifier code.
Now my task, as written in the instructions, is to make a POST request, https://login.eveonline.com/oauth/token to exchange the authorization code for an access token.
And here is a complete stupor. Having no programming skills, I don’t even understand what exactly is required of me.
Those. You can make a POST request, for example, via curl.
I'm trying the following code:

<?php
$encoded = base64_encode($string='<b>bla</b>:<b>blablabla'</b>);
$request_headers = array('Authorization' => 'Basic ' . $encoded, 'Content-Type' => 'application/x-www-form-urlencoded', 'Host' => 'login.eveonline.com');
$code = $_GET['code'];
$postfieldStr = array('grant_type' => 'authorization_code', 'code' => $code);
$ch = curl_init('https://login.eveonline.com/oauth/token');
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfieldStr); 
$out = curl_exec($ch);
curl_close($ch);
print_r($out);
?>

The output is one, and I still do not understand how how can I get this token.
Could someone explain in as much detail (within reason) how to do all this?
PS I purposely replaced the client id and secret key with bla-bla

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Oblomov, 2019-03-01
@Oblomow

In general, we managed to find the finished code on github.
The question is over.

V
Vladislav Vlastovskiy, 2019-02-26
@VlastV

EVE Online uses the OAuth2: Authorization Code Grant as they state at the start of the documentation.
Accordingly, to understand what, where and why to send, you can read the OAuth2 documentation - authorization through code, for example, an explanation from DigitalOcean

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question