{"record":{"id":"e7d10b319cdf5be6","repo":"AlistGo/alist","slug":"refresh-access-token-failed-w","errorCode":null,"errorMessage":"refresh access_token failed: %w","messagePattern":"refresh access_token failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/123_open/client.go","lineNumber":82,"sourceCode":"\t}\n\td.tokenMu.Lock()\n\tdefer d.tokenMu.Unlock()\n\n\tif !d.tokenNeedsRefresh() {\n\t\treturn nil\n\t}\n\tif d.RefreshToken == \"\" || d.ClientID == \"\" || d.ClientSecret == \"\" {\n\t\tif d.accessTokenExpiredAt.IsZero() {\n\t\t\t// expiry unknown and no way to refresh: keep using the token and let\n\t\t\t// the API surface the authoritative error\n\t\t\treturn nil\n\t\t}\n\t\treturn errNoRefreshCredentials\n\t}\n\n\ttoken, err := d.client.OAuth.RefreshToken(ctx, d.ClientID, d.ClientSecret, d.RefreshToken)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"refresh access_token failed: %w\", err)\n\t}\n\td.AccessToken = token.AccessToken\n\tif token.RefreshToken != \"\" {\n\t\td.RefreshToken = token.RefreshToken\n\t}\n\td.accessTokenExpiredAt = time.Now().Add(time.Duration(token.ExpiresIn) * time.Second)\n\td.client.SetToken(d.AccessToken, d.accessTokenExpiredAt)\n\t// persist immediately: the previous refresh_token is already void\n\td.persist()\n\treturn nil\n}\n\n// persist writes the rotated credentials back to the storage config.\nfunc (d *Open123) persist() {\n\tif d.persistFn != nil {\n\t\td.persistFn()\n\t\treturn\n\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/123_open/client.go#L64-L100","documentation":"Error \"refresh access_token failed: %w\" thrown in AlistGo/alist.","triggerScenarios":"Thrown at drivers/123_open/client.go:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-authenticate the storage: obtain a new refresh_token via the provider's OAuth flow and update the storage configuration.","Verify client_id/client_secret are correct and the refresh token has not been revoked or expired."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}