MCPcopy
hub / github.com/opentrace/opentrace / _register_client

Function _register_client

agent/src/opentrace_agent/cli/auth.py:114–139  ·  view source on GitHub ↗

Dynamically register a new OAuth client.

(registration_endpoint: str, redirect_uris: list[str])

Source from the content-addressed store, hash-verified

112
113
114def _register_client(registration_endpoint: str, redirect_uris: list[str]) -> dict[str, Any]:
115 """Dynamically register a new OAuth client."""
116 body = json.dumps(
117 {
118 "client_name": CLIENT_NAME,
119 "redirect_uris": redirect_uris,
120 "grant_types": ["authorization_code"],
121 "response_types": ["code"],
122 "scope": SCOPES,
123 "token_endpoint_auth_method": "none",
124 }
125 ).encode()
126
127 req = urllib.request.Request(
128 registration_endpoint,
129 data=body,
130 headers={"Content-Type": "application/json", "Accept": "application/json"},
131 )
132 with urllib.request.urlopen(req, timeout=15) as resp:
133 client = json.loads(resp.read())
134
135 if "client_id" not in client:
136 raise RuntimeError("Dynamic registration response missing client_id")
137
138 save_client(client)
139 return client
140
141
142def _ensure_client(disco: dict[str, Any], redirect_uris: list[str]) -> dict[str, Any]:

Callers 1

_ensure_clientFunction · 0.85

Calls 2

save_clientFunction · 0.90
readMethod · 0.80

Tested by

no test coverage detected