authenticate method
Authenticate user with encrypted phone number
Implementation
Future<Map<String, dynamic>> authenticate(String phoneNumber,String token) async {
try {
String encryptedPhone = EncryptionService.encryptPhoneNumber(phoneNumber);
final response = await http.post(
Uri.parse(baseUrl),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $token',
},
body: jsonEncode({
"brand": "IOH",
"consent": "N",
"workflow": [
{
"channel": "silent_auth",
"mobileNumberTo": encryptedPhone
},
{
"channel": "sms",
"mobileNumberTo": encryptedPhone
}
]
}),
);
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else {
return {
"error": "Failed to authenticate. Status: ${response.statusCode}",
"response": response.body
};
}
} catch (e) {
return {"error": "An error occurred: $e"};
}
}