refreshToken abstract method

Future<T>? refreshToken(
  1. T currentUser
)

Refresh the token

It exposes the currentUser model, where you get the refresh token.

If the token is successfully refreshed, a new copy of the current user holding the new token is return.

It is automatically invoked after the duration return by autoRefreshOrSignOut parameter of RM.injectAuth.

It can also be manually invoked using InjectedAuth.auth.refreshToken method. see _AuthService.refreshToken.

Example:

 @override
 Future<User?>? refreshToken(User? currentUser) async {

  final response = await http.post( ... );

  if (response.codeStatus == 200){
   return currentUser!.copyWith(
     token: response.body['id_token'],
     refreshToken: response.body['refresh_token'],
     tokenExpiration: DateTime.now().add(
         Duration(seconds: response.body[expires_in] ),
     ),
   );
  }

  return null;

 }

Implementation

Future<T>? refreshToken(T currentUser);