Function getToken

  • Use this function to retrieve tokens by using a username and password.

    If you are using this function in a browser environment you need to specify the origin. If you try to access a wikimedia server you need to be on a wikimedia domain. all other domains are blocked. see https://phabricator.wikimedia.org/T22814 and https://noc.wikimedia.org/conf/highlight.php?file=CommonSettings.php#:~:text=%24wgCrossSiteAJAXdomains

    you can pass in a custom axios instance to use for the requests. this is mainly intended for cors circumvention purposes. use for example axios-over-http to do the actual requests on a server. the only requirement for these axios instances is that they have the same api as the axios package. the only required function is the main axios() function.

    Parameters

    • username: string

      The username of the user

    • password: string

      The password of the user

    • Optional config: GetTokenConfig

      The config for the function

    Returns Promise<Token>

    A object containing the token and the cookie

    Throws

    If the login was not successful

    Example

    const token = await getToken('your wikidata username', 'your wikidata password');
    upload(item, {
    summary: 'test update',
    authToken: token
    });

Generated using TypeDoc