-
Notifications
You must be signed in to change notification settings - Fork 3
Client tokens
Client tokens are OAuth tokens that identify your application but not the user. With this token, only the anonymous parts of the API can be accessed, such as searching for gifs, viewing gifs, accessing collections, etc. A client token can be obtained automatically without user interaction and is normally used before the user logs in.
To get a token, you send a request like this:
POST /v2/oauth/client HTTP/1.1
Host: api.redgifs.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id=xxxxxxxxxx
&client_secret=xxxxxxxxxx
(For information on getting your client id and secret, see client credentials.)
Possible errors:
- 401: unknown client id, possibly a typo.
- 403: client disabled, please contact us.
A successful response will look like this:
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"access_token": "your.secret.access.token",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "read"
}
You can then use the token to access all other parts of the API, for example:
GET /v2/gifs/search?order=trending&count=80 HTTP/1.1
Host: api.redgifs.com
Authorization: Bearer your.secret.access.token
Tokens are issued for 24 hours. You then need to request a new token. It's a good idea to track the expiration time (see expires_in
in the response) and request a new token a few minutes before the current one expires.