getRequestToken static method

Future<RequestToken> getRequestToken(
  1. String apiKey,
  2. String apiSecretKey,
  3. String redirectURI,
  4. bool forceLogin,
)

Request user authorization token

Implementation

static Future<RequestToken> getRequestToken(
  String apiKey,
  String apiSecretKey,
  String redirectURI,
  bool forceLogin,
) async {
  final authParams = requestHeader(
    apiKey: apiKey,
    redirectURI: redirectURI,
  );
  final params = await httpPost(
    REQUEST_TOKEN_URL,
    authParams,
    apiKey,
    apiSecretKey,
  );

  var authorizeURI = '$AUTHORIZE_URI?oauth_token=${params!['oauth_token']}';
  //
  if (forceLogin) {
    authorizeURI += '&force_login=true';
  }
  final requestToken = RequestToken(params, authorizeURI);
  if (requestToken.callbackConfirmed.toLowerCase() != 'true') {
    throw StateError('oauth_callback_confirmed mast be true');
  }

  return requestToken;
}