# Authorization
# How does authorization work on Humtog?
You must pass a valid access_token in the Authorization header of your request. (except for login and register calls of course). You do not need to generate access_token anywhere on site. It will be given to you as the result of https://humtog.com/api/token/login and https://humtog.com/api/token/register API calls.
# PHP Example:
Here's a PHP example, when using the Guzzle HTTP library:
$response = $client->request('GET', '/api/user', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$accessToken,
],
]);
# Javascript Example:
As a simple tip, it may be easier to config your Ajax library to send the Authorization header automatically in every request. For example, when using Axios library:
if (accessToken.length) {
window.axios.defaults.headers.common = {
'Authorization': 'Bearer ' + accessToken,
};
}
# Login
After a successful login, you'll be given a valid access_token which later you'll be using for authorization.
# Resource URL
https://humtog.com/api/token/login
# Resource Method
POST
# Params
| Name | Required | Type | Description |
|---|---|---|---|
username | Yes | string | The username used for login. Humtog supports both user's username and email. Note that even if you're using email, you still have to send it as username. |
password | Yes | string | Password used for login. |
# Example Response
{
"token_type": "Bearer",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImRmNWExMmE5ODg2NWE5M2QzMzY5ZTE0OTM5YjlhZjE2N2I3ZjVlMzNkNWJjOWQ1MzA4MTk0ODkwZmI4NDQzMDYzYmY5ZTdlNzkyZDQ3MGMyIn0.eyJhdWQiOiIxMSIsImp0aSI6ImRmNWExMmE5ODg2NWE5M2QzMzY5ZTE0OTM5YjlhZjE2N2I3ZjVlMzNkNWJjOWQ1MzA4MTk0ODkwZmI4NDQzMDYzYmY5ZTdlNzkyZDQ3MGMyIiwiaWF0IjoxNTIwNDA5MTc2LCJuYmYiOjE1MjA0MDkxNzYsImV4cCI6MTU1MTk0NTE3Niwic3ViIjoiMyIsInNjb3BlcyI6W119.b4LeL6K2mmhaM42WL5vieQkEslH_OrLbtuJHpNneUK4bMsrkfrjEhRhZC_fIA4YPkuKHIzC-OCczzPMHDrmcT18-8NlB_fzsT9ff4wzjvCeqn5rIZeNe6swaC-zhg3MvR_pzyoeRuEZ19Aig1lYsRKiMaSLfqbEA_eksoZwvCL-LybWhKA4AKVd4RtnenOnZQ_fu2fv4MeVIbk_03udS8wd9z5_4K-wL5BGU_6RwF3ED72ZKfWhpFicANOA6PK3huEH7YjjsWAaQE5P2GlsIa3m5QruS76BLPsswOVDBso7CEsho3RQVrT9bRuupBMyUylMG3PS9s1H_R2BloGQw8P-lje3GyzeOSchCKHXqj2e9VW4FeHQzRC0Fvy2bng8Es3Wdqy3SvatrDCdykj4pkdyB1bAj--gBN9d0oPRdKM6MfJ0I0E0-CXud57jBk23ALjaNhpoZ4Dnq5ADw_toT5Dk_8zfMsb1f4VfN9rTOgF19uwOKY0uleoUjnW75rq1kXI5b7QK71d3T9SGSVythboQDvAyHNW1w_xKLTz_5q7KPoDXjczpXGi3OHB946JcPhtD41E0j3YTwnCs-JIkVT4zUskPTXu-vGaJSBz7djLiIaX_VeBS2E_Jvo37LeBPBvLfUQizMjyq-CIJgdtFprHXWPzDkBkP3hdQVyOyKXSo",
"expires_in": 31536000
}
# Register
At the moment, Humtog only supports authentication via password for API calls. After a successful registration, you'll be given a valid access_token which later you're be using for authorization.
# Resource URL
https://humtog.com/api/token/register
# Resource Method
POST
# Params
| Name | Required | Type | Description |
|---|---|---|---|
name | Sometimes | string | Full name of the user. If type is email name is required |
username | Yes | string | The username used for login. |
email | Yes | string | A valid email address used for login and password resets. |
password | Yes | string | Password used for login. |
password_confirmation | Yes | string | A second copy of the password, required to prevent accidental typing of passwords. |
type | No | string | Can be annonymous or email. If type is set to annonymous, user don't have to enter their name. |
location_id | Yes | ineger | Location id from list of all Locations |
g-recaptcha-response | Yes | string | A key gerenerated by Google Recaptcha. Follow Google's installation guide for more info. |
# Example Response
{
"token_type": "Bearer",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImRmNWExMmE5ODg2NWE5M2QzMzY5ZTE0OTM5YjlhZjE2N2I3ZjVlMzNkNWJjOWQ1MzA4MTk0ODkwZmI4NDQzMD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