getJWTToken method
Implementation
@override
Future<Either<Failure, AuthResponse>> getJWTToken({
required String publicKey,
required String privateKey,
}) async {
try {
final authorization = base64Encode(utf8.encode('$publicKey:$privateKey'));
final response = await httpClient.post(
'/login',
options: Options(
headers: {
'Authorization': 'Basic $authorization',
},
),
data: jsonEncode({
'public_key': publicKey,
'private_key': privateKey,
}),
);
final authResponse = AuthResponse.fromJson(response.data);
return Right(authResponse);
} catch (e) {
return Left(
Failure(
message: e.toString(),
),
);
}
}