Skip to content

Client tokens

Justin Forest edited this page Jul 26, 2022 · 13 revisions

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.

Getting the token

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 how to get client id and secret, see below.

The 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 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