iwf
    Preparing search index...

    Class BearerTokenAuth

    Uses an already-issued OAuth 2.0 access token without browser APIs or refresh credentials. Create a new provider when replacing a rejected or expired token. HTTP failures are converted to credential-free errors; request configs and raw responses are never attached.

    Implements

    Index
    • Returns the authenticated client. Use only with trusted Wikimedia/Wikibase endpoints.

      Returns AxiosInstance

      An axios client that validates expiry and injects the bearer header on each request

      const client = auth.getAxiosInstance();
      
    • Retrieves and caches an authenticated CSRF token per site origin.

      Parameters

      • site: string

        Wikibase site URL

      Returns Promise<string>

      An authenticated CSRF token

      If the API returns a missing or anonymous token

      const csrf = await auth.getCsrfToken('https://www.wikidata.org');
      
    • Returns the supplied token unless it is within 60 seconds of expiry or has been rejected.

      Returns Promise<string>

      The bearer access token

      If a replacement token is required

      const token = await auth.getValidAccessToken();