{"id":"13c753456123c63d","repo":"docker/cli","slug":"failed-to-get-device-code-w","errorCode":null,"errorMessage":"failed to get device code: %w","messagePattern":"failed to get device code: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/oauth/api/api.go","lineNumber":78,"sourceCode":"\t}\n\n\tdeviceCodeURL := a.TenantURL + \"/oauth/device/code\"\n\tresp, err := postForm(ctx, deviceCodeURL, strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn State{}, err\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn State{}, tryDecodeOAuthError(resp)\n\t}\n\n\tvar state State\n\terr = json.NewDecoder(resp.Body).Decode(&state)\n\tif err != nil {\n\t\treturn state, fmt.Errorf(\"failed to get device code: %w\", err)\n\t}\n\n\treturn state, nil\n}\n\nfunc tryDecodeOAuthError(resp *http.Response) error {\n\tvar body map[string]any\n\tif err := json.NewDecoder(resp.Body).Decode(&body); err == nil {\n\t\tif errorDescription, ok := body[\"error_description\"].(string); ok {\n\t\t\treturn errors.New(errorDescription)\n\t\t}\n\t}\n\treturn errors.New(\"unexpected response from tenant: \" + resp.Status)\n}\n\n// WaitForDeviceToken polls the tenant to get access/refresh tokens for the user.\n// This should be called after GetDeviceCode, and will block until the user has\n// authenticated or we have reached the time limit for authenticating (based on","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/internal/oauth/api/api.go#L60-L96","documentation":"Error \"failed to get device code: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at internal/oauth/api/api.go:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}