MCPcopy Index your code
hub / github.com/coder/coder / showSuccess

Function showSuccess

scripts/oauth2/oauth2-test-server.go:238–292  ·  view source on GitHub ↗
(w http.ResponseWriter, code string, tokenResp *TokenResponse, opts ServerOptions)

Source from the content-addressed store, hash-verified

236}
237
238func showSuccess(w http.ResponseWriter, code string, tokenResp *TokenResponse, opts ServerOptions) {
239 log.Printf("SUCCESS: Token exchange completed")
240 tokenJSON, _ := json.MarshalIndent(tokenResp, "", " ")
241
242 serverNote := "The server will shut down automatically in a few seconds."
243 if opts.KeepRunning {
244 serverNote = "The server will continue running. Press Ctrl+C in the terminal to stop it."
245 }
246
247 html := fmt.Sprintf(`
248<!DOCTYPE html>
249<html>
250<head>
251 <title>OAuth2 Test - Success</title>
252 <style>
253 body { font-family: Arial, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; }
254 .status { padding: 20px; margin: 20px 0; border-radius: 5px; }
255 .success { background: #d4edda; color: #155724; }
256 pre { background: #f5f5f5; padding: 15px; overflow-x: auto; }
257 .section { margin: 20px 0; }
258 code { background: #e9ecef; padding: 2px 4px; border-radius: 3px; }
259 </style>
260</head>
261<body>
262 <h1>OAuth2 Test Server - Success</h1>
263 <div class="status success">
264 <h2>Authorization Successful!</h2>
265 <p>Successfully exchanged authorization code for tokens.</p>
266 </div>
267
268 <div class="section">
269 <h3>Authorization Code</h3>
270 <pre>%s</pre>
271 </div>
272
273 <div class="section">
274 <h3>Token Response</h3>
275 <pre>%s</pre>
276 </div>
277
278 <div class="section">
279 <h3>Next Steps</h3>
280 <p>You can now use the access token to make API requests:</p>
281 <pre>curl -H "Coder-Session-Token: %s" %s/api/v2/users/me | jq .</pre>
282 </div>
283
284 <div class="section">
285 <p><strong>Note:</strong> %s</p>
286 </div>
287</body>
288</html>`, code, string(tokenJSON), tokenResp.AccessToken, cmp.Or(os.Getenv("BASE_URL"), "http://localhost:3000"), serverNote)
289
290 w.Header().Set("Content-Type", "text/html")
291 _, _ = fmt.Fprint(w, html)
292}

Callers 1

mainFunction · 0.85

Calls 2

SetMethod · 0.65
HeaderMethod · 0.45

Tested by

no test coverage detected