authorizeFromCallback method

  1. @override
Future<AuthResult?> authorizeFromCallback(
  1. String callbackUrl
)
override

Implementation

@override
Future<AuthResult?> authorizeFromCallback(String callbackUrl) async {
  final parsed = Uri.parse(callbackUrl);
  final oauthToken = parsed.queryParameters['oauth_token'] as String;
  final oauthVerifier = parsed.queryParameters['oauth_verifier'] as String;

  final res = await _post(_accessTokenPath, {
    'oauth_token': oauthToken,
    'oauth_verifier': oauthVerifier,
  });

  if (res == null) throw Exception("Couldn't authroize");

  final decodedRes = Uri.splitQueryString(res);

  return AuthResult(
    accessToken: decodedRes['oauth_token'],
    tokenSecret: decodedRes['oauth_token_secret'],
  );
}