(project_id: str)
| 132 | |
| 133 | |
| 134 | def get_api_key(project_id: str): |
| 135 | api_endpoint = get_api_endpoint() |
| 136 | api_endpoint = api_endpoint.rstrip("/") |
| 137 | req = requests.post( |
| 138 | f"{api_endpoint}/projects/{project_id}/api-tokens", |
| 139 | json={ |
| 140 | "project_id": project_id, |
| 141 | "name": "api token", |
| 142 | "x_token": "???", |
| 143 | }, |
| 144 | headers={"Authorization": f"Bearer {get_access_token()}"}, |
| 145 | ) |
| 146 | api_key = req.json()["token"] |
| 147 | return api_key |
| 148 | |
| 149 | |
| 150 | @codecarbon.command("get-token", short_help="Get project token") |
no test coverage detected
searching dependent graphs…