{"id":"1365ee70a9f6ea2e","repo":"tiangolo/fastapi","slug":"no-jessica-token-provided","errorCode":null,"errorMessage":"No Jessica token provided","messagePattern":"No Jessica token provided","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"docs_src/bigger_applications/app_an_py310/dependencies.py","lineNumber":13,"sourceCode":"from typing import Annotated\n\nfrom fastapi import Header, HTTPException\n\n\nasync def get_token_header(x_token: Annotated[str, Header()]):\n    if x_token != \"fake-super-secret-token\":\n        raise HTTPException(status_code=400, detail=\"X-Token header invalid\")\n\n\nasync def get_query_token(token: str):\n    if token != \"jessica\":\n        raise HTTPException(status_code=400, detail=\"No Jessica token provided\")\n","sourceCodeStart":1,"sourceCodeEnd":14,"githubUrl":"https://github.com/tiangolo/fastapi/blob/42a41db11f6882807ac3c057b942178d53b97438/docs_src/bigger_applications/app_an_py310/dependencies.py#L1-L14","documentation":"Raised by the get_query_token dependency when the query parameter named token is not equal to \"jessica\", returning HTTP 400. Unlike the header checks, this validates a URL query parameter, demonstrating FastAPI's ability to gate the app/router on a query value.","triggerScenarios":"A request whose URL lacks ?token=jessica, e.g. GET / without the query param, or GET /?token=wrong.","commonSituations":"Clients building URLs without the token query param; query stripped by a proxy/redirect; assuming auth is header-only.","solutions":["Append ?token=jessica to the request URL.","When using TestClient, pass params={\"token\": \"jessica\"}.","Confirm the param name and value against the dependency definition."],"exampleFix":"# before\nclient.get(\"/\")\n# after\nclient.get(\"/\", params={\"token\": \"jessica\"})","handlingStrategy":"validation","validationCode":"# Ensure the token query param is set\nparams = {\"token\": \"jessica\"}\nclient.get(\"/\", params=params)","typeGuard":"def has_query_token(params: dict) -> bool:\n    return params.get(\"token\") == \"jessica\"","tryCatchPattern":null,"preventionTips":["Append ?token=jessica to every URL.","Use params= in TestClient rather than string concatenation.","Confirm query params survive any proxy/redirect."],"tags":["fastapi","authentication","query-params","dependencies"],"analyzedSha":"42a41db11f6882807ac3c057b942178d53b97438","analyzedAt":"2026-08-04T19:23:32.007Z","schemaVersion":2}