fetchTokenByRefreshToken function
Future<LogtoRefreshTokenResponse>
fetchTokenByRefreshToken(
{ - required Client httpClient,
- required String tokenEndPoint,
- required String clientId,
- required String refreshToken,
- String? resource,
- List<String>? scopes,
})
Implementation
Future<LogtoRefreshTokenResponse> fetchTokenByRefreshToken({
required http.Client httpClient,
required String tokenEndPoint,
required String clientId,
required String refreshToken,
String? resource,
List<String>? scopes,
}) async {
Map<String, dynamic> payload = {
'grant_type': refreshTokenGrantType,
'client_id': clientId,
'refresh_token': refreshToken,
};
if (resource != null && resource.isNotEmpty) {
payload.addAll({'resource': resource});
}
if (scopes != null && scopes.isNotEmpty) {
payload.addAll({'scope': scopes.join(' ')});
}
final response = await httpClient.post(Uri.parse(tokenEndPoint),
headers: {'Content-Type': _requestContentType}, body: payload);
var body = httpResponseHandler(response);
return LogtoRefreshTokenResponse.fromJson(body);
}