Creates a new OAuthAuth instance
OAuth 2.0 configuration
Returns an axios instance pre-configured with the OAuth Bearer token.
Each request made through this instance will include an Authorization: Bearer header
populated with a freshly-validated access token.
Configured axios instance
Gets a CSRF token for the specified site using the OAuth Bearer token.
For OAuth CORS requests the MediaWiki API requires both:
crossorigin= query parameterAuthorization: Bearer <token> headerThe site URL (e.g. https://www.wikidata.org)
The CSRF token
Handles the OAuth 2.0 callback after Wikimedia redirects back.
Reads ?code and ?state from the current URL, validates state,
exchanges the authorization code for tokens, and stores them.
Must be called on the page matching redirectUri.
Resolves when tokens have been stored
Initiates the OAuth 2.0 Authorization Code + PKCE flow. Redirects the browser to the Wikimedia authorization endpoint.
Must be called in a browser environment.
Resolves before the redirect (the page will navigate away)
OAuth 2.0 authentication provider using Authorization Code flow with PKCE.
Designed for use in browser environments where a redirect-based OAuth flow is possible. Uses
sessionStorageto temporarily hold PKCE state during the authorization redirect.The public interface (
getCsrfToken,getAxiosInstance,getUserAgent) is compatible withBotPasswordAuth, so the two can be used interchangeably in upload options.Example