{"record":{"id":"a50bbe0ad05085ce","repo":"router-for-me/CLIProxyAPI","slug":"xai-device-code-device-authorization-endpoint-is","errorCode":null,"errorMessage":"xai device code: device authorization endpoint is required","messagePattern":"xai device code: device authorization endpoint is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":129,"sourceCode":"}\n\n// StartDeviceFlow requests a device code from xAI.\nfunc (a *XAIAuth) StartDeviceFlow(ctx context.Context) (*DeviceCodeResponse, error) {\n\tdiscovery, errDiscover := a.Discover(ctx)\n\tif errDiscover != nil {\n\t\treturn nil, errDiscover\n\t}\n\treturn a.RequestDeviceCode(ctx, discovery.DeviceAuthorizationEndpoint, discovery.TokenEndpoint)\n}\n\n// RequestDeviceCode requests a device authorization code from the given endpoint.\nfunc (a *XAIAuth) RequestDeviceCode(ctx context.Context, deviceAuthorizationEndpoint, tokenEndpoint string) (*DeviceCodeResponse, error) {\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tdeviceAuthorizationEndpoint = strings.TrimSpace(deviceAuthorizationEndpoint)\n\tif deviceAuthorizationEndpoint == \"\" {\n\t\treturn nil, fmt.Errorf(\"xai device code: device authorization endpoint is required\")\n\t}\n\n\tform := url.Values{\n\t\t\"client_id\": {ClientID},\n\t\t\"scope\":     {Scope},\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, deviceAuthorizationEndpoint, strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xai device code: create request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\treq.Header.Set(\"Accept\", \"application/json\")\n\n\tresp, err := a.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xai device code request failed: %w\", err)\n\t}\n\tdefer func() {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L111-L147","documentation":"Error \"xai device code: device authorization endpoint is required\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:129 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the discovery document provides device_authorization_endpoint before starting device flow.","Re-fetch the xAI discovery document if the endpoint was missing."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}