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)
| 122 | |
| 123 | |
| 124 | def 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 | ) |
nothing calls this directly
no test coverage detected
searching dependent graphs…