commaai/openpilot · error · NotImplementedError

no redirect implemented for method {method}

Error message

no redirect implemented for method {method}

What it means

auth_redirect_link() builds an OAuth authorize URL and only supports 'google', 'github', and 'apple' (there is also a provider-id map earlier in the function). Any other method string hits the else branch and raises NotImplementedError. This is an exhaustive-match guard over the supported login providers.

Source

Thrown at openpilot/tools/lib/auth.py:94

      'prompt': 'select_account',
    })
    return 'https://accounts.google.com/o/oauth2/auth?' + urlencode(params)
  elif method == 'github':
    params.update({
      'client_id': '28c4ecb54bb7272cb5a4',
      'scope': 'read:user',
    })
    return 'https://github.com/login/oauth/authorize?' + urlencode(params)
  elif method == 'apple':
    params.update({
      'client_id': 'ai.comma.login',
      'response_type': 'code',
      'response_mode': 'form_post',
      'scope': 'name email',
    })
    return 'https://appleid.apple.com/auth/authorize?' + urlencode(params)
  else:
    raise NotImplementedError(f"no redirect implemented for method {method}")


def login(method):
  # Let the OS select an available port to avoid colliding with other services.
  web_server = ClientRedirectServer(('localhost', 0), ClientRedirectHandler)
  oauth_uri = auth_redirect_link(method, web_server.server_port)
  print(f'To sign in, use your browser and navigate to {oauth_uri}')
  webbrowser.open(oauth_uri, new=2)

  while True:
    web_server.handle_request()
    if 'code' in web_server.query_params:
      break
    elif 'error' in web_server.query_params:
      print('Authentication Error: "{}". Description: "{}" '.format(
        web_server.query_params['error'],
        web_server.query_params.get('error_description')), file=sys.stderr)
      break

View on GitHub (pinned to 516ec1e682)

Solutions

  1. Use one of the exact lowercase names: 'google', 'github', or 'apple'
  2. If surfacing this in a CLI, validate/normalize method against {'google','github','apple'} before calling
  3. To add a provider, extend the provider-id map and add a branch returning its authorize URL

Example fix

# before
login('gmail')

# after
SUPPORTED = {'google', 'github', 'apple'}
method = method.lower().strip()
assert method in SUPPORTED, f"unsupported auth method {method!r}; choose from {sorted(SUPPORTED)}"
login(method)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_AUTH = {'google', 'github', 'apple'}
assert method.lower() in SUPPORTED_AUTH, f"auth method must be one of {sorted(SUPPORTED_AUTH)}"

Type guard

def is_supported_auth_method(method: str) -> bool:
    """True when method is an implemented OAuth provider name."""
    return isinstance(method, str) and method.lower() in {'google', 'github', 'apple'}

Try / catch

try:
    login(method)
except NotImplementedError as e:
    raise SystemExit(f'{e}; supported: google, github, apple') from e

Prevention

When it happens

Trigger: Calling auth_redirect_link(method) or login(method) with e.g. 'microsoft', 'email', or a typo like 'Github' (case-sensitive); code enumerating a config-driven provider list that includes names never implemented.

Common situations: User typing the provider name wrong on the CLI; new provider added to config but not to the three branches; case mismatch from user input.

Related errors


AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15). Data as JSON: /api/errors/cbc9bc0b67257f1b. Report an issue: GitHub.