MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / generate_dev_token

Function generate_dev_token

app/api/agentops/api/auth.py:124–156  ·  view source on GitHub ↗

Generate a development JWT token for testing with a specific project ID. This should only be used for development/testing purposes. Args: project_id: The project ID to include in the token Returns: str: The generated JWT token Raises: ValueError: If JW

(project_id: str)

Source from the content-addressed store, hash-verified

122
123
124def generate_dev_token(project_id: str) -> str:
125 """
126 Generate a development JWT token for testing with a specific project ID.
127 This should only be used for development/testing purposes.
128
129 Args:
130 project_id: The project ID to include in the token
131
132 Returns:
133 str: The generated JWT token
134
135 Raises:
136 ValueError: If JWT secret is not configured
137 """
138 if not JWT_SECRET_KEY:
139 raise ValueError("JWT_SECRET_KEY environment variable is not set")
140
141 # Create a JWT payload for development purposes
142 payload = JWTPayload(
143 exp=_generate_jwt_timestamp(),
144 aud="authenticated",
145 project_id=project_id,
146 project_prem_status="premium", # Default to premium for dev tokens
147 api_key="dev-token", # Placeholder API key for dev tokens
148 dev=True, # Mark as development token
149 )
150
151 # Encode the payload
152 return jwt.encode(
153 payload.asdict(),
154 JWT_SECRET_KEY,
155 algorithm=JWT_ALGO,
156 )

Callers

nothing calls this directly

Calls 4

asdictMethod · 0.95
JWTPayloadClass · 0.85
_generate_jwt_timestampFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…