getAccessToken method
Implementation
Future<Map<String, dynamic>> getAccessToken(String code, String ssoClientId,
String grantType, String tokenType) async {
var body = {
"code": code,
"client_id": ssoClientId,
"grant_type": grantType,
"token_type": tokenType,
};
String formData = body.keys
.map((key) =>
"${Uri.encodeComponent(key)}=${Uri.encodeComponent(body[key].toString())}")
.join("&");
final response =
await http.post(Uri.parse('$edxBaseUrl/oauth2/access_token/'),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formData);
var data = json.decode(response.body);
return data; // Returns the API response
}