POST Authentication


POST Authenticate & Token Generation

If you prefer to authenticate and generate your access tokens via your own website or web application you can do so by making a POST request to the endpoint listed below. Be sure to send the required parameters when making an authentication request.

{primary} Regardless of how you generate your access tokens, all tokens generated are saved on the authenticated users RoadLeagues account. You can manage all your created access tokens directly from within your RoadLeagues account.


Endpoint

Method URI
POST https://roadleagues.com/api/v1/authenticate


POST Data Parameters

"name" : "{NAME}"          // Optional - String
"email" : "{EMAIL}"        // Required - String
"password" : "{PASSWORD}"  // Required - String


Example Response

{
    "access_token" : "eyJ0eXAiOiJKV1QiLCJhbIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvcm9hZGxlYWd1ZXMuZGV2XC9hcGlcL3YxXC9hdXRoZW50aWNhYXQiOjE1ODU2NTkzNjIsIm5iZiI6MTU4NTY1OTM2MiwianRpIjoicjV6OFh1WmRSRDN2cVFUTyIsInNiI6MSwicHJ2IjoiODdlMGFmMWVmOWZkMTU4MTJmZGVjOTcxNTNhMTRlwNDc1NDZhYSJ9.TFl7oIxlDCYaAmbUaxMVGMgUkrp4Y9Y0W9zFPdtxY2s",
    "token_type" : "bearer",
    "expires_in" : "Never",
    "status" : "success"
}

Example Requests

{primary} A couple of examples using Ajax & PHP cURL on how you might go about making a POST request for this endpoint. Remember to replace the placeholders with your own credentials.

Example POST Request - Ajax

$.ajax({
  type: "POST",
  url: "https://roadleagues.com/api/v1/authenticate",
  data: {
    "name": "{NAME}",
    "email": "{EMAIL}",
    "password": "{PASSWORD}",
  },
  dataType: "JSON",
  cache: false,
  success: function (data) {
    console.log(data);
  }
});


Example POST Request - PHP cURL

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://roadleagues.com/api/v1/authenticate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "name={NAME}&email={EMAIL}&password={PASSWORD}",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;