getAccessToken method
Implementation
Future<Map<String, String>> getAccessToken(
String signature,
String address,
) async {
try {
final Map<String, String> headers = {'Content-Type': 'application/json'};
final Map<String, dynamic> requestBody = {
"json": {
'address': address,
'chain': "ethereum",
'signature': signature,
'walletName': "metamask"
}
};
final response = await http.post(
Uri.parse('https://sdk-iriko.huddle01.com/trpc/auth.login'),
headers: headers,
body: jsonEncode(requestBody),
);
if (response.statusCode == 200) {
final Map<String, dynamic> responseData = jsonDecode(response.body);
final String text =
responseData['result']['data']['json']['accessToken'] as String;
return {'message': text};
} else {
throw Exception('failed to get access token');
}
} catch (error) {
throw Exception('error getting access token => $error');
}
}