Skip to main content

Authentication

Introduction

Authentication Auth Type bearer token is used to authenticate the user. The user needs to pass the token in the header to access the API. The token is generated by the server and is valid for a certain period of time

How to use

To authenticate the user, you need to pass the token in the header. The token is generated by the server and is valid for a certain period of time. The token is passed in the Authorization header with the value Bearer {token}.

Shell
curl 'https://myapi.sports.uz/v1/countries' -H 'Authorization: Bearer {token}' -H 'Accept: application/json'
JavaScript
const headers
{
'Authorization': 'Bearer {token}',
'Accept': 'application/json'
}
fetch('https://myapi.sports.uz/v1/countries', { headers: headers })
Python
import requests

headers = {
'Authorization': 'Bearer {token}',
'Accept': 'application/json'
}

response = requests.get('https://myapi.sports.uz/v1/countries', headers=headers)
PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => 'https://myapi.sports.uz/v1/countries',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer {token}',
'Accept: application/json'
],
]);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

Error Authentication

If the user passes an invalid token, the server will return a 401 status code with the message Your request was made with invalid credentials.

{
"statusCode": 401,
"message": "Your request was made with invalid credentials"
}