login method
Metodo per autenticarsi e ottenere il token.
Implementation
Future<String?> login(String studentID, String password) async {
final response = await http.post(
Uri.parse('$endpoint/autenticazione'),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: {
'key': "r4g4zz3tt1",
'matricola': studentID,
'stringaAutenticazione': password,
},
);
if (response.statusCode == 200) {
final Map<String, dynamic> data = json.decode(response.body);
token = data['output'];
return token;
} else {
throw Exception('Errore nella richiesta: ${response.statusCode}');
}
}