getTokenAndUserID method
Implementation
Future<Map<String, dynamic>> getTokenAndUserID({
required String appid,
required String redirectUrl,
required String code,
required String appSecret,
}) async {
try {
var url = Uri.parse('https://api.instagram.com/oauth/access_token');
final body = {
'client_id': appid,
'redirect_uri': redirectUrl,
'client_secret': appSecret,
'code': code,
'grant_type': 'authorization_code'
};
final response = await http.post(url, body: body);
debugPrint('response: ${response.body}');
return jsonDecode(response.body);
} catch (e) {
debugPrint('Error: $e');
throw Exception(e);
}
}