getDMToken method

Future<Map<String, dynamic>?> getDMToken(
  1. String tenant_key,
  2. String token
)

Implementation

Future<Map<String, dynamic>?> getDMToken(
    String tenant_key, String token) async {
  var body = {
    'platform_key': tenant_key,
  };
  String formData = body.keys
      .map((key) =>
          "${Uri.encodeComponent(key)}=${Uri.encodeComponent(body[key].toString())}")
      .join("&");

  final response = await http.post(
    Uri.parse('$edxBaseUrl/api/ibl/manager/consolidated-token/proxy/'),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': 'JWT ${token}'
    },
    body: formData,
  );

  var data = json.decode(response.body);

  return data; // Return null if redirectUri is not in the response or token is not found
}