Session
The token mechanism
To authenticate your requests, you need a token to send alongside those requests. In order to receive such a token, you have to present your credentials to the system.
The system will answer with a token, which is valid for 4 hours. Use it as
the value of the auth_token
parameter for your further requests.
Logging in with partner credentials
curl -v -v -d "api_key=<api key placeholder>" \
-d "secret=<secret placholder>" -X POST \
"https://api-v2.swissunihockey.ch/bo/session/auth"
Logging in with anlass credentials
Anlass with a game that has already been played:
curl -v -v -d 'anlass_id=473798' \
-d "password=<password placeholder>" -X POST \
"http://127.0.0.1:5000/bo/session/auth_anlass"
Here's a game that will be played some time from now:
curl -v -v -d 'anlass_id=483837' \
-d "password=<password placeholder>" -X POST \
"http://127.0.0.1:5000/bo/session/auth_anlass"
Validate token
Definition
PUT https://api-v2.swissunihockey.ch/bo/session/validate
Tells whether the auth_token is valid for the provided anlass_id.
Parameters:
- auth_token
- string
- anlass_id
- integer
Sample request with curl:
curl -v -v -d "auth_token=<auth_token>" \
-d "anlass_id=<anlass id>" -X POST \
"https://api-v2.swissunihockey.ch/bo/session/validate"
Sample response with valid token for anlass_id:
{
"status": {
"code": 0,
"msg": "ok"
},
"token": "da2e78801a7d10e9a89a"
}
Sample response with invalid token for anlass_id:
{
"status": {
"code": 1,
"msg": "authentication token expired or invalid"
}
}
Performing further requests
Provide the parameter auth_token=<your received token>
so the API knows you are allowed to perform the request.