getAuthorizeUrl method
Generates the url to be used for fetching the authorization code.
Implementation
String getAuthorizeUrl(
{required String clientId,
String responseType = 'code',
String? redirectUri,
List<String>? scopes,
bool enableState = true,
String? state,
String? codeChallenge,
Map<String, dynamic>? customParams}) {
final params = <String, dynamic>{
'response_type': responseType,
'client_id': clientId
};
if (redirectUri != null && redirectUri.isNotEmpty) {
params['redirect_uri'] = redirectUri;
}
if (scopes != null && scopes.isNotEmpty) {
params['scope'] = serializeScopes(scopes);
}
if (enableState && state != null && state.isNotEmpty) {
params['state'] = state;
}
if (codeChallenge != null && codeChallenge.isNotEmpty) {
params['code_challenge'] = codeChallenge;
params['code_challenge_method'] = 'S256';
}
if (customParams != null) {
params.addAll(customParams);
}
return OAuth2Utils.addParamsToUrl(authorizeUrl, params);
}