refreshToken method

Map<String, dynamic> refreshToken(
  1. String token, [
  2. String guard = '',
  3. Duration? expiresIn
])

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 token
  • refresh_token: the new refresh token
  • expires_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);
}