{"record":{"id":"05a17980e5be5251","repo":"AlistGo/alist","slug":"empty-token-returned-from-online-api","errorCode":null,"errorMessage":"empty token returned from online API","messagePattern":"empty token returned from online API","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/aliyundrive_open/util.go","lineNumber":86,"sourceCode":"\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tif resp.RefreshToken != \"\" && resp.AccessToken != \"\" {\n\t\treturn resp.RefreshToken, resp.AccessToken, nil\n\t}\n\tif resp.ErrorMessage != \"\" {\n\t\tif res != nil && res.StatusCode() == http.StatusTooManyRequests {\n\t\t\treturn d.refreshTokenWithLegacyFallback(ctx, resp.ErrorMessage, retryAfterFromResponse(res))\n\t\t}\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to refresh token: %s\", resp.ErrorMessage)\n\t}\n\tif res != nil && res.StatusCode() == http.StatusTooManyRequests {\n\t\treturn d.refreshTokenWithLegacyFallback(ctx, http.StatusText(http.StatusTooManyRequests), retryAfterFromResponse(res))\n\t}\n\tif e.Code != \"\" || e.Message != \"\" {\n\t\treturn d.refreshTokenWithPost(ctx, d.OauthTokenURL)\n\t}\n\treturn \"\", \"\", fmt.Errorf(\"empty token returned from online API\")\n}\n\nfunc (d *AliyundriveOpen) refreshTokenWithLegacyFallback(ctx context.Context, message string, retryAfter time.Duration) (string, string, error) {\n\tif d.OauthTokenURL != legacyOauthTokenURL {\n\t\tlog.Warnf(\"[ali_open] online refresh API is rate-limited, trying legacy fallback: %s\", legacyOauthTokenURL)\n\t\tif refresh, access, err := d.refreshTokenWithPost(ctx, legacyOauthTokenURL); err == nil {\n\t\t\treturn refresh, access, nil\n\t\t} else if _, ok := err.(*refreshRateLimitError); !ok {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\t}\n\treturn \"\", \"\", &refreshRateLimitError{\n\t\tmessage:    fmt.Sprintf(\"failed to refresh token: %s\", message),\n\t\tretryAfter: retryAfter,\n\t}\n}\n\nfunc (d *AliyundriveOpen) refreshTokenWithPost(ctx context.Context, url string) (string, string, error) {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/aliyundrive_open/util.go#L68-L104","documentation":"Thrown by refreshTokenWithOnlineAPI when the online token-exchange API succeeds but returns neither refresh_token/access_token nor an error message, so no credentials can be obtained. Fires on upstream API misbehavior or empty responses, typically alongside 429 responses that exhausted the legacy fallback path.","triggerScenarios":"Thrown at drivers/aliyundrive_open/util.go:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a valid token in the storage configuration and save it again.","If the token expired, re-login or refresh it through the provider and update the configuration."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","contentChangedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}