getRequestToken method

Future<String> getRequestToken()

Implementation

Future<String> getRequestToken() async {
  try {
    final res = await _post(_requestTokenPath, {
      'oauth_callback': Uri.encodeFull(redirectUri),
    });

    if (res == null) throw Exception();

    final body = Uri.splitQueryString(res);

    if (body.containsKey('oauth_token')) {
      return body['oauth_token'] as String;
    } else {
      throw Exception();
    }
  } on Exception catch (_) {
    throw Exception("Couldn't get request token");
  }
}