Skip to content

CampusRequest requires CLIENT_ID/CLIENT_SECRET even in device mode #35

Description

@nycomp

Problem

When using Campus with mode="device", the CampusRequest class still requires CLIENT_ID and CLIENT_SECRET environment variables, even though device mode is designed for public clients (like CLI tools) that use Bearer token authentication instead.

Root Cause

In campus_python/json_client/__init__.py, the CampusRequest.__init__() method always calls reset_authorization() which requires:

  • CLIENT_ID environment variable
  • CLIENT_SECRET environment variable

This happens BEFORE the caller can set Bearer authorization via set_bearer_authorization().

Expected Behavior

Device mode should:

  1. NOT require CLIENT_ID/CLIENT_SECRET environment variables
  2. Allow Bearer token authentication to be set via set_bearer_authorization()

Server mode should:

  1. Require CLIENT_ID/CLIENT_SECRET environment variables
  2. Use Basic auth with client credentials by default

Proposed Solution

  1. Add a mode parameter to CampusRequest.__init__()
  2. Only call reset_authorization() when mode="server"
  3. In device mode, don't set any default authorization (Bearer will be set later)
  4. Pass self._mode from Campus class to CampusRequest instances

Impact

This affects the campus-cli tool which uses device mode for user authentication via OAuth device flow.


Note: This issue has been fixed in PR #34. This issue is being migrated from the incorrect repository (campus-devcontainer-flask) to the correct one (campus-api-python).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions