MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / ExchangeToken

Method ExchangeToken

internal/api/client.go:254–268  ·  view source on GitHub ↗

ExchangeToken calls POST /api/auth/exchange.

(exchangeCode string)

Source from the content-addressed store, hash-verified

252
253// ExchangeToken calls POST /api/auth/exchange.
254func (c *Client) ExchangeToken(exchangeCode string) (*ExchangeResponse, error) {
255 status, data, err := c.post(CLIBaseURL+"/api/auth/exchange", map[string]string{"exchange_code": exchangeCode}, false)
256 if err != nil {
257 return nil, fmt.Errorf("failed to exchange token: %w", err)
258 }
259 if status >= 300 {
260 return nil, fmt.Errorf("exchange failed (%d): %s", status, string(data))
261 }
262
263 var result ExchangeResponse
264 if err := json.Unmarshal(data, &result); err != nil {
265 return nil, fmt.Errorf("failed to parse exchange response: %w (body: %s)", err, string(data))
266 }
267 return &result, nil
268}

Callers 2

startAuthCmdFunction · 0.80
runInitFunction · 0.80

Calls 1

postMethod · 0.95

Tested by

no test coverage detected