- @override
Asks this instance to store a AuthToken
for server
.
This method must persist the token t
. If issuedFrom
is not null, it must associate
the issuedFrom
AuthCode
with t
in storage, such that t
can be found again
by issuedFrom
's AuthCode.code
, even if t
has been refreshed later.
Source
@override Future storeToken(AuthServer server, AuthToken t, {AuthCode issuedFrom}) async { var storage = new ManagedToken.fromToken(t); var query = new Query<ManagedToken>(context)..values = storage; if (issuedFrom != null) { query.where.code = whereEqualTo(issuedFrom.code); query.values.code = issuedFrom.code; var outToken = await query.updateOne(); if (outToken == null) { throw new AuthServerException(AuthRequestError.invalidGrant, new AuthClient(t.clientID, null, null)); } } else { await query.insert(); } return pruneTokens(t.resourceOwnerIdentifier); }