getAccesToken method

Future<String?> getAccesToken(
  1. String code
)

Get the access token from the code.

Implementation

Future<String?> getAccesToken(String code) async {
  try {
    response = await http.post(
      Uri.parse(accesTokenUrl),
      headers: {'Accept': 'application/json'},
      body: {
        'client_id': params!.clientId,
        'client_secret': params!.clientSecret,
        'code': code,
        'redirect_uri': params!.callbackUrl,
      },
    );
    return jsonDecode(response.body)['access_token'];
  } catch (e) {
    message = "Status Code: ${response.statusCode}\n\n Response Body: ${response.body} \n\n Error: ${e.toString()}";
    return null;
  }
}