getSecurityChallenges function
Fetches the list of security challenges one must answer to access the account. Check if this is needed using areSecurityChallengesNeeded.
Implementation
Future<List<SecurityChallenge>> getSecurityChallenges(
AccessToken accessToken) async {
final headers = {
'authorization': 'Bearer $accessToken',
};
final response = await request(
http.get, _mojangApi, 'user/security/challenges',
headers: headers);
if (response.statusCode == 401) {
throw AuthException(AuthException.invalidCredentialsMessage);
}
final list = parseResponseList(response);
return list.map((f) => SecurityChallenge.fromJson(f)).toList();
}