Repository navigation
fix(auth): token() passes a relative path — absolute URL was double-prefixed and 404ed live - #63
Merged
Merged
Conversation
…refixed token() built an absolute URL (base_url + url_prefix + "/oauth/token") and passed it to client.post(), but CampusRequest._build_url() always prepends the client's base_url (it expects a relative path, like every other resource method). Every token() call therefore hit https://host/https://host/auth/v1/oauth/token and 404ed against real deployments — verified live: curl to the same endpoint returns 200 while the client returns NotFoundError. This predates #61 (the original "/token" construction had the same shape) and is the actual root cause of the long-standing "with_app_session 404s" in campus-classroom#24. It survived all in-repo tests because campus's Flask test transport routes absolute URLs leniently. Pass a relative path (matching oauth.poll_for_token's "/oauth/token") and pin it: the path tests now use a deliberately non-empty mock base_url, and a regression test asserts the path stays relative (#62). Verified live against the dev deployment with this fix: grant 200 (scope campus.profile), and with_app_session() read reaches the campus.api resource lookup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #62
What
AuthRoot.token()built an absolute URL (base_url + url_prefix + "/oauth/token") and passed it toclient.post()— butCampusRequest._build_url()always prepends the client's base_url (it expects a relative path, like every other resource method). Everytoken()call hithttps://host/https://host/auth/v1/oauth/token→ 404, verified live: curl to the identical endpoint returns 200 while the client returnsNotFoundError.This predates #61 (its "/token" construction had the same shape) and is the actual root cause of the long-standing "with_app_session 404s" in campus-classroom#24. It survived all in-repo tests because campus's Flask test transport routes absolute URLs leniently.
The fix passes a relative path — the same call shape as
oauth.poll_for_token's"/oauth/token".Tests
test_token_path_is_relative_not_double_prefixedasserts the path handed to the client stays relative (AuthRoot.token() passes an absolute URL to client.post() — CampusRequest double-prefixes it, so every token() call 404s against real deployments #62).Verified live (dev deployment, 2026-10-02)
With this fix shadowed into campus-classroom's venv:
auth.token(grant_type="client_credentials")→ 200 (Bearer, scopecampus.profile), andwith_app_session()→ campus.api assignments read reaches the resource lookup (409 not-found for a bogus id — authn passed).