{"record":{"id":"9f630a0f4d69adaf","repo":"netbirdio/netbird","slug":"failed-to-request-access-token-with-error-v","errorCode":null,"errorMessage":"failed to request access token with error: %v","messagePattern":"failed to request access token with error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/internal/auth/device_flow.go","lineNumber":221,"sourceCode":"\n\treturn parsedURL.String()\n}\n\nfunc (d *DeviceAuthorizationFlow) requestToken(info AuthFlowInfo) (TokenRequestResponse, error) {\n\tform := url.Values{}\n\tform.Add(\"client_id\", d.providerConfig.ClientID)\n\tform.Add(\"grant_type\", HostedGrantType)\n\tform.Add(\"device_code\", info.DeviceCode)\n\n\treq, err := http.NewRequest(\"POST\", d.providerConfig.TokenEndpoint, strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn TokenRequestResponse{}, fmt.Errorf(\"failed to create request access token: %v\", err)\n\t}\n\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tres, err := d.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn TokenRequestResponse{}, fmt.Errorf(\"failed to request access token with error: %v\", err)\n\t}\n\n\tdefer func() {\n\t\terr := res.Body.Close()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}()\n\n\tbody, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn TokenRequestResponse{}, fmt.Errorf(\"failed reading access token response body with error: %v\", err)\n\t}\n\n\tif res.StatusCode > 499 {\n\t\treturn TokenRequestResponse{}, fmt.Errorf(\"access token response returned code: %s\", string(body))\n\t}\n","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/internal/auth/device_flow.go#L203-L239","documentation":"Fires in requestToken (called by WaitToken) when the HTTP POST to the token endpoint fails at the transport level. WaitToken polls repeatedly, so this commonly fires transiently on each poll tick during device flow — network drops, DNS failures, or an unreachable IdP — and the caller treats it as a poll iteration error rather than a fatal condition.","triggerScenarios":"Thrown at client/internal/auth/device_flow.go:221 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["WaitToken already retries on the next poll interval; ensure transient errors are logged, not fatal","Check DNS resolution and connectivity to the token endpoint host","Verify the token endpoint is reachable from restricted networks (corporate proxies may block it)","If the IdP endpoint moved, update the provider configuration"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","contentChangedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}