DIYgod/RSSHub · error · ConfigNotFoundError

pixiv not login

Error message

pixiv not login

What it means

Thrown by getNSFWSeriesNovels after getToken() returns a falsy value. getToken() refreshes the pixiv access token by POSTing to oauth.secure.pixiv.net/auth.token; if that response lacks data.access_token the module-level token variable stays null and this fires. It means a refreshToken WAS configured (the previous guard passed) but the OAuth refresh itself failed.

Source

Thrown at lib/routes/pixiv/novel-api/series/nsfw.ts:40

            series_id: seriesId,
            last_order: offset,
        }),
    });
    return rsp.data as AppNovelSeries;
}

export async function getNSFWSeriesNovels(seriesId: string, limit: number = 10): Promise<SeriesFeed> {
    if (limit > 30) {
        limit = 30;
    }

    if (!config.pixiv || !config.pixiv.refreshToken) {
        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。');
    }

    const token = await getToken();
    if (!token) {
        throw new ConfigNotFoundError('pixiv not login');
    }

    const seriesResponse = await got(`${baseUrl}/ajax/novel/series/${seriesId}`, {
        headers: {
            ...maskHeader,
            Authorization: 'Bearer ' + token,
        },
    });
    const seriesData = seriesResponse.data as SeriesDetail;

    let offset = seriesData.body.total - limit;
    if (offset < 0) {
        offset = 0;
    }
    const appSeriesData = await getNovelSeries(seriesId, offset, token);

    const items = await Promise.all(
        appSeriesData.novels.map(async (novel) => {

View on GitHub (pinned to bed535e087)

Solutions

  1. Re-obtain a fresh PIXIV_REFRESHTOKEN from a working pixiv login flow and replace the old value.
  2. Ensure the RSSHub host can reach oauth.secure.pixiv.net (route through a proxy/VPN if the server is in a blocked region).
  3. Flush the cached access token (key 'pixiv:accessToken') so the next call re-attempts the refresh instead of returning the cached null.
  4. Inspect logs around the refreshToken POST for the pixiv OAuth error body.
Defensive patterns

Strategy: validation

Validate before calling

import { getToken } from './token';
async function ensurePixivToken(): Promise<string | null> {
  const token = await getToken();
  return token || null;
}
// call before the NSFW series request:
const token = await ensurePixivToken();
if (!token) {
  // handle expired/invalid refresh token (regenerate PIXIV_REFRESHTOKEN)

Type guard

const isUsableToken = (t: unknown): t is string => typeof t === 'string' && t.length > 0;

Try / catch

try {
  const token = await getToken();
  if (!token) throw new ConfigNotFoundError('pixiv not login');
} catch (e) {
  if (e instanceof ConfigNotFoundError) {
    // refresh failed: clear cached 'pixiv:accessToken', prompt token regeneration
  }
}

Prevention

When it happens

Trigger: PIXIV_REFRESHTOKEN is present but invalid, expired, revoked, or belongs to a different client; the oauth endpoint rejected the grant; the refresh call was blocked at the network layer (pixiv blocks many CN IPs); the response was cached empty under key 'pixiv:accessToken' for up to 3600s.

Common situations: Refresh token expired (they are single-use / time-limited); RSSHub server IP region-blocked by pixiv; a stale empty token cached under 'pixiv:accessToken' for an hour; token copied incorrectly with trailing whitespace.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/44b145be8d7e09fb. Report an issue: GitHub.