getAppleAuthUrl static method

String getAppleAuthUrl({
  1. required String callbackUrl,
})

Generate Apple OAuth URL

Implementation

static String getAppleAuthUrl({required String callbackUrl}) {
  final clientId = Auth.config.appleClientId;
  if (clientId == null || clientId.isEmpty) {
    throw AuthException(
        'Apple Sign In is not configured. Set APPLE_CLIENT_ID.');
  }

  final state = _generateState(callbackUrl);
  final nonce = _generateNonce();

  _storeAuthData(state, nonce, callbackUrl);

  final params = {
    'client_id': clientId,
    'redirect_uri': callbackUrl,
    'response_type': 'code id_token',
    'scope': 'name email',
    'state': state,
    'nonce': nonce,
    'response_mode': 'form_post',
  };

  return _buildUrl('https://appleid.apple.com/auth/authorize', params);
}