This API is used for receiving global messages to hitbox users.
Endpoint | Description |
---|---|
GET /oauthaccess/:user | Get Third Party OAuth Access |
POST /oauthaccess/:user | Remove Application From Account |
GET /userfromtoken/:token | Get User From Token |
OAuth Flow | OAuth Flow |
Get list of third party applications that have access to user
https://www.hitbox.tv/api/oauthaccess/Test-Account?authToken=SuperSecret
{
"apps":[
{
"name":"Third Party Site",
"description":"App Description"
}
]
}
Remove applications from user
https://www.hitbox.tv/api/oauthaccess/Test-Account?authToken=SuperSecret
{
"error":false,
"success":true
}
Get username a token belongs to.
https://www.hitbox.tv/api/userfromtoken/SuperSecret
Token exists.
{
"user_name":"test-account"
}
Token doesn't exist.
[]
You will need to setup a server that can handle redirects from the hitbox API after authorization and a app_token
and app_secret
, which can be generated from your hitbox account tab.
Send the user to the hitbox API Authentication Page:
https://api.hitbox.tv/oauth/login?app_token=app_token
You should then handle three types of flows:
If the user hasn't already authenticated with your application and accepts authorization, the user will be redirected to:
https://redirect_uri?request_token=request_token.
Once the user is redirected, You then need to exchange the request_token
for an authToken
. To do this you need to send the following request:
{
"request_token":"",
"app_token":"",
"hash":""
}
The hash
value is a Base64 Encode of of the app_token
and app_secret
. As an example, You can open up Chrome/Firefox Developer Tool go to the console and type btoa(app_token+app_secret);
and the result will be your hash
.
You will then get back either two responses:
This access_token
is the equivalent of a regular authToken
. You are now able to use this on the hitbox API for the authentication user.
{
"access_token":""
}
authentication_failed
If the user has already authenticated with your application and you exchanged the request_token, the hitbox API will skip the login screen. The user will be redirected with an authToken
:
https://redirect_uri?authToken=authToken
Note: You can add force_auth=true to the URL query to force login again.
The hitbox API will redirect to the following URL when there's an error with authorization. (EX: User Canceled)
https://redirect_uri?error=error