requestAuthorization method
Requests an Authorization Code to be used in the Authorization Code grant.
Implementation
Future<AuthorizationResponse> requestAuthorization(
{required String clientId,
List<String>? scopes,
String? codeChallenge,
bool enableState = true,
String? state,
Map<String, dynamic>? customParams,
BaseWebAuth? webAuthClient,
Map<String, dynamic>? webAuthOpts}) async {
webAuthClient ??= this.webAuthClient;
if (enableState) {
state ??= randomAlphaNumeric(25);
}
final authorizeUrl = getAuthorizeUrl(
clientId: clientId,
redirectUri: redirectUri,
scopes: scopes,
enableState: enableState,
state: state,
codeChallenge: codeChallenge,
customParams: customParams);
// Present the dialog to the user
final result = await webAuthClient.authenticate(
url: authorizeUrl,
callbackUrlScheme: customUriScheme,
redirectUrl: redirectUri,
opts: webAuthOpts);
return AuthorizationResponse.fromRedirectUri(result, state);
}