authorize method

Future<Credential> authorize()

Starts the authentication flow.

This method will start a local http server and open the authorization server's authentication page in a browser.

The server will be stopped when the cancel method is called or when the authentication flow is completed.

Implementation

Future<Credential> authorize() async {
  var state = flow.authenticationUri.queryParameters['state']!;

  _requestsByState[state] = Completer();
  await _startServer(port, htmlPage, redirectMessage);
  urlLancher(flow.authenticationUri.toString());

  var response = await _requestsByState[state]!.future;

  return flow.callback(response);
}