refreshToken method
Creates a new token from a given refresh token.
This function verifies the given refresh token and if it is valid, creates a
new token using the createToken
method.
The expiresIn
parameter is the duration after which the new token will
expire. If not provided, the token will expire after 1 hour.
Returns a map containing the following keys:
access_token
: the new JWT tokenrefresh_token
: the new refresh tokenexpires_in
: the duration after which the new token will expire in seconds
Implementation
Map<String, dynamic> refreshToken(
String token, [
String guard = '',
Duration? expiresIn,
]) {
final jwt = verify(token, guard, 'refresh_token');
_userPayload = jwt;
return createToken(guard, expiresIn, true);
}