S
S
Suguru_Evillione2020-02-21 20:26:52
PHP
Suguru_Evillione, 2020-02-21 20:26:52

How to generate a token on login?

There is an Intersect Engine, it has an API, but the documentation for this API is not yet complete. There is a section with an input
5e5012abf34aa415596184.jpeg
But how to create a token, I did not understand. I leafed through the documentation on this issue on the php site and still did not catch up ... I would be grateful for the help

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nokimaro, 2020-02-21
@Suguru_Evillione

Judging by the documentation from the screenshot
1. the request must be POST
2. the request data must be a json string in post-data

$data = array(
    "grant_type" => "password", 
    "username" => "......",
    "password" => "......",
);                                                                    
$data_string = json_encode($data);                                                                                   
                                                                                                                     
$ch = curl_init('http://domain.tld/api/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_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   
                                                                                                                     
$result = curl_exec($ch);

var_dump($result);

A
Anton Shamanov, 2020-02-21
@SilenceOfWinter

welcome to the world of river engineering) open the code and read..

Y
Yuri Kulaxyz, 2020-02-21
@Kulaxyz

So there is all the necessary information. You just need to send a Post request to the given url with login, hashed password and type. You will receive an authorization token in response.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question