MCPcopy Create free account
hub / github.com/mlco2/codecarbon / get_api_key

Function get_api_key

codecarbon/cli/main.py:134–147  ·  view source on GitHub ↗
(project_id: str)

Source from the content-addressed store, hash-verified

132
133
134def 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")

Callers 2

get_tokenFunction · 0.85
configFunction · 0.85

Calls 3

get_api_endpointFunction · 0.90
get_access_tokenFunction · 0.90
jsonMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…