MCPcopy Index your code
hub / github.com/AgentOps-AI/agentops / get_jwt_token

Function get_jwt_token

app/api/agentops/api/auth.py:96–121  ·  view source on GitHub ↗

Dependency to extract and verify JWT token from Authorization header Usage: - Include this as a dependency in route functions - The JWT payload will be passed to the route function

(authorization: str = Header(None))

Source from the content-addressed store, hash-verified

94
95
96async def get_jwt_token(authorization: str = Header(None)) -> JWTPayload:
97 """
98 Dependency to extract and verify JWT token from Authorization header
99
100 Usage:
101 - Include this as a dependency in route functions
102 - The JWT payload will be passed to the route function
103 """
104 if not authorization:
105 raise HTTPException(status_code=401, detail="Authorization header missing")
106
107 try:
108 # Extract token from "Bearer <token>" format
109 scheme, token = authorization.split()
110 if scheme.lower() != "bearer":
111 raise HTTPException(status_code=401, detail="Invalid authentication scheme")
112
113 return verify_jwt(token)
114 except ValueError:
115 raise HTTPException(status_code=401, detail="Invalid token format")
116 except jwt.ExpiredSignatureError:
117 raise HTTPException(status_code=401, detail="Token has expired")
118 except jwt.InvalidAudienceError:
119 raise HTTPException(status_code=401, detail="Invalid audience")
120 except jwt.InvalidTokenError:
121 raise HTTPException(status_code=401, detail="Invalid token")
122
123
124def generate_dev_token(project_id: str) -> str:

Calls 2

HeaderFunction · 0.85
verify_jwtFunction · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…