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:
- NOT require
CLIENT_ID/CLIENT_SECRET environment variables
- Allow Bearer token authentication to be set via
set_bearer_authorization()
Server mode should:
- Require
CLIENT_ID/CLIENT_SECRET environment variables
- Use Basic auth with client credentials by default
Proposed Solution
- Add a
mode parameter to CampusRequest.__init__()
- Only call
reset_authorization() when mode="server"
- In device mode, don't set any default authorization (Bearer will be set later)
- 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).
Problem
When using
Campuswithmode="device", theCampusRequestclass still requiresCLIENT_IDandCLIENT_SECRETenvironment 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, theCampusRequest.__init__()method always callsreset_authorization()which requires:CLIENT_IDenvironment variableCLIENT_SECRETenvironment variableThis happens BEFORE the caller can set Bearer authorization via
set_bearer_authorization().Expected Behavior
Device mode should:
CLIENT_ID/CLIENT_SECRETenvironment variablesset_bearer_authorization()Server mode should:
CLIENT_ID/CLIENT_SECRETenvironment variablesProposed Solution
modeparameter toCampusRequest.__init__()reset_authorization()whenmode="server"self._modefromCampusclass toCampusRequestinstancesImpact
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).