login method
Implementation
Future<Map<String, dynamic>?> login(
String username,
String password,
String clientId,
String grant_type,
String tokenType,
String asymmetricJwt) async {
final body = {
'username': username,
'password': password,
'grant_type': grant_type,
"client_id": clientId,
"token_type": tokenType,
"asymmetric_jwt": asymmetricJwt
};
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; // Return null if redirectUri is not in the response or token is not found
}