buildAuthorizationUrlStatic static method
Static method - builds a complete OAuth2 authorization URL with all required parameters
Note: PKCE (code_challenge) is optional and disabled by default for Frappe compatibility. Frappe OAuth2 does not support PKCE parameters.
Implementation
static String buildAuthorizationUrlStatic({
required String baseUrl,
required String clientId,
required String redirectUri,
required String scope,
String? codeChallenge, // Made optional - Frappe doesn't support PKCE
String? codeChallengeMethod, // Made optional - Frappe doesn't support PKCE
required String state,
String? customEndpoint,
Map<String, String> additionalParams = const {},
}) {
final endpoint =
customEndpoint ??
'$baseUrl/api/method/frappe.integrations.oauth2.authorize';
final params = <String, String>{
'client_id': clientId,
'response_type': 'code',
'redirect_uri': redirectUri,
'scope': scope,
'state': state,
// Only include PKCE parameters if provided and non-empty
// Frappe OAuth2 does not support PKCE
if (codeChallenge != null && codeChallenge.isNotEmpty)
'code_challenge': codeChallenge,
if (codeChallengeMethod != null && codeChallengeMethod.isNotEmpty)
'code_challenge_method': codeChallengeMethod,
...additionalParams,
};
return _buildUrlWithParams(endpoint, params);
}