getDeviceCode method

Future<Map<String, dynamic>> getDeviceCode(
  1. String clientId,
  2. String scope,
  3. String deviceCodeUrl
)

Implementation

Future<Map<String, dynamic>> getDeviceCode(
    String clientId, String scope, String deviceCodeUrl) async {
  final response = await http.post(
    Uri.parse(deviceCodeUrl), // Replace with your provider's URL
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: {'client_id': clientId, 'scope': scope},
  );

  if (response.statusCode == 200) {
    return json.decode(response.body);
  } else {
    throw Exception('Failed to get device code');
  }
}