{"record":{"id":"f2494042eff5cd3f","repo":"DIYgod/RSSHub","slug":"this-user-is-an-r18-creator-pixiv-refreshtoken-is","errorCode":null,"errorMessage":"This user is an R18 creator, PIXIV_REFRESHTOKEN is required.\npixiv RSS is disabled due to the lack of relevant config.\n該用戶爲 R18 創作者，需要 PIXIV_REFRESHTOKEN。","messagePattern":"This user is an R18 creator, PIXIV_REFRESHTOKEN is required\\.\npixiv RSS is disabled due to the lack of relevant config\\.\n該用戶爲 R18 創作者，需要 PIXIV_REFRESHTOKEN。","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/routes/pixiv/novel-api/series/nsfw.ts","lineNumber":35,"sourceCode":"        headers: {\n            ...maskHeader,\n            Authorization: 'Bearer ' + token,\n        },\n        searchParams: queryString.stringify({\n            series_id: seriesId,\n            last_order: offset,\n        }),\n    });\n    return rsp.data as AppNovelSeries;\n}\n\nexport async function getNSFWSeriesNovels(seriesId: string, limit: number = 10): Promise<SeriesFeed> {\n    if (limit > 30) {\n        limit = 30;\n    }\n\n    if (!config.pixiv || !config.pixiv.refreshToken) {\n        throw new ConfigNotFoundError('This user is an R18 creator, PIXIV_REFRESHTOKEN is required.\\npixiv RSS is disabled due to the lack of relevant config.\\n該用戶爲 R18 創作者，需要 PIXIV_REFRESHTOKEN。');\n    }\n\n    const token = await getToken();\n    if (!token) {\n        throw new ConfigNotFoundError('pixiv not login');\n    }\n\n    const seriesResponse = await got(`${baseUrl}/ajax/novel/series/${seriesId}`, {\n        headers: {\n            ...maskHeader,\n            Authorization: 'Bearer ' + token,\n        },\n    });\n    const seriesData = seriesResponse.data as SeriesDetail;\n\n    let offset = seriesData.body.total - limit;\n    if (offset < 0) {\n        offset = 0;","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/pixiv/novel-api/series/nsfw.ts#L17-L53","documentation":"Thrown by getNSFWSeriesNovels (pixiv R18 novel series path) when config.pixiv or config.pixiv.refreshToken is falsy. Pixiv gates R18/NSFW novel series behind an authenticated account, so RSSHub refuses the request before any network call rather than returning partial or login-walled data. It is a ConfigNotFoundError, signalling a deployment-configuration problem, not a bad user request.","triggerScenarios":"Requesting the NSFW novel series route for an R18 series while PIXIV_REFRESHTOKEN is unset, empty string, or config.pixiv is entirely undefined (env var never loaded). Reached only via the NSFW branch, i.e. when the caller knows the series is R18.","commonSituations":"Fresh RSSHub deploy without pixiv env vars set; .env file missing or not loaded by the process; Docker container started without -e PIXIV_REFRESHTOKEN; var name misspelled; config module read before env population.","solutions":["Set PIXIV_REFRESHTOKEN in your RSSHub environment (obtain it via the pixiv login refresh-token flow documented at https://docs.rsshub.app/deploy/config#pixiv), then restart the instance.","Confirm the variable is actually loaded: print config.pixiv in a debug route or check startup logs.","If you only need safe-for-work series content, call the SFW series route instead so auth is not required.","For Docker/Compose, ensure the env var is passed through to the container and not shadowed by an empty value."],"exampleFix":"// before: .env has no pixiv entry\n// after (in .env):\nPIXIV_REFRESHTOKEN=your_refresh_token_here","handlingStrategy":"validation","validationCode":"import { config } from '@/config';\nfunction canFetchNSFWSeries(): boolean {\n  return Boolean(config.pixiv && config.pixiv.refreshToken);\n}\n// before calling getNSFWSeriesNovels:\nif (!canFetchNSFWSeries()) {\n  // surface a friendly 'PIXIV_REFRESHTOKEN not configured' notice instead of throwing\n}","typeGuard":"const hasPixivAuth = (c: typeof config): c is typeof config & { pixiv: { refreshToken: string } } =>\n  Boolean(c.pixiv && typeof c.pixiv.refreshToken === 'string' && c.pixiv.refreshToken.length > 0);","tryCatchPattern":"try {\n  const feed = await getNSFWSeriesNovels(seriesId, limit);\n} catch (e) {\n  if (e instanceof ConfigNotFoundError) {\n    // config problem: instruct operator, do not retry\n  }\n  throw e;\n}","preventionTips":["Run a startup config check that fails fast when PIXIV_REFRESHTOKEN is missing for NSFW routes.","Centralize the config.pixiv.refreshToken guard in one helper (hasPixivAuth) and reuse it.","Document which routes require the token so operators set it during initial deploy."],"tags":["pixiv","config","nsfw","authentication","novel"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}