DiscordPHP Documentation

TokenStoreInterface

Where users' OAuth2 tokens are kept between restarts.

Deliberately separate from the part cache, which is built to lose data: a TTL, a sweep or an eviction policy dropping a token would sign that user out, and Discord replaces the refresh token every time it is used, so a lost one cannot be recovered. Keep tokens somewhere durable, and treat them as the credentials they are.

Tags
since
10.59.0

Table of Contents

Methods

delete()  : PromiseInterface<string|int, bool>
get()  : PromiseInterface<string|int, ?AccessToken>
set()  : PromiseInterface<string|int, bool>

Methods

delete()

public delete(string $key) : PromiseInterface<string|int, bool>
Parameters
$key : string

What the token was stored under.

Return values
PromiseInterface<string|int, bool>

get()

public get(string $key) : PromiseInterface<string|int, ?AccessToken>
Parameters
$key : string

What the token was stored under.

Return values
PromiseInterface<string|int, ?AccessToken> —

The token, or null if none is stored.

set()

public set(string $key, AccessToken $token) : PromiseInterface<string|int, bool>
Parameters
$key : string

What to store the token under.

$token : AccessToken

The token.

Return values
PromiseInterface<string|int, bool>
On this page

Search results