@@ -10,29 +10,29 @@ import (
1010 "net/http"
1111)
1212
13- // exchangeResult is the dashboard 's answer: the same shape as the MCP key
14- // exchange (POST /api/mcp/key) .
13+ // exchangeResult is the key exchange 's answer: the same shape as the MCP key
14+ // exchange.
1515type exchangeResult struct {
1616 APIKey string `json:"apiKey"`
1717 OrganizationID string `json:"organizationId"`
1818 OrganizationName string `json:"organizationName"`
1919}
2020
21- // errExchangeNotAvailable means the dashboard has no CLI key exchange yet.
21+ // errExchangeNotAvailable means the API has no CLI key exchange yet.
2222var errExchangeNotAvailable = errors .New ("this Moderation API account cannot sign in from the CLI yet" )
2323
2424// exchangeForOrganizationKey trades a Clerk OAuth access token for an
2525// organization key of the organization the user picked on the consent screen.
26- // The dashboard makes one key per user and device name.
27- func exchangeForOrganizationKey (ctx context.Context , client * http.Client , dashboardURL , accessToken , deviceName string ) (* exchangeResult , error ) {
28- if err := requireHTTPS (dashboardURL ); err != nil {
26+ // The API makes one key per user and device name.
27+ func exchangeForOrganizationKey (ctx context.Context , client * http.Client , keyExchangeURL , accessToken , deviceName string ) (* exchangeResult , error ) {
28+ if err := requireHTTPS (keyExchangeURL ); err != nil {
2929 return nil , err
3030 }
3131 payload , err := json .Marshal (map [string ]string {"deviceName" : deviceName })
3232 if err != nil {
3333 return nil , err
3434 }
35- req , err := http .NewRequestWithContext (ctx , http .MethodPost , dashboardURL + "/api/cli/key" , bytes .NewReader (payload ))
35+ req , err := http .NewRequestWithContext (ctx , http .MethodPost , keyExchangeURL , bytes .NewReader (payload ))
3636 if err != nil {
3737 return nil , err
3838 }
@@ -42,7 +42,7 @@ func exchangeForOrganizationKey(ctx context.Context, client *http.Client, dashbo
4242
4343 res , err := client .Do (req )
4444 if err != nil {
45- return nil , fmt .Errorf ("could not reach the Moderation API dashboard : %w" , err )
45+ return nil , fmt .Errorf ("could not reach the Moderation API: %w" , err )
4646 }
4747 defer res .Body .Close ()
4848 body , _ := io .ReadAll (io .LimitReader (res .Body , 1 << 20 ))
@@ -61,6 +61,6 @@ func exchangeForOrganizationKey(ctx context.Context, client *http.Client, dashbo
6161 case result .Message != "" :
6262 return nil , errors .New (result .Message )
6363 default :
64- return nil , fmt .Errorf ("the dashboard returned %s for the CLI sign-in" , res .Status )
64+ return nil , fmt .Errorf ("the Moderation API returned %s for the CLI sign-in" , res .Status )
6565 }
6666}
0 commit comments