splatnet3_scraper.auth.NSO.get_gtoken(session_token, f_token_url=None)

Obtains the gtoken from the session token.

The GameWebToken, or gtoken, is used to authenticate requests to the Nintendo Switch Online API. This method will obtain the gtoken from the session token. The process of obtaining a gtoken is as follows:

  1. Obtain the user access token and the id_token from the session

    token.

  2. Use the user access token to obtain the user’s information.

  3. Use the id_token and the user’s information to obtain the first

    f_token, the request ID, and the timestamp.

  4. Use the first f_token, the request ID, the timestamp, and the

    id_token to obtain the web_service_access_token.

  5. Use the web_service_access_token to obtain the second

    f_token, request ID, and timestamp.

  6. Use the second f_token, request ID, timestamp, and the

    web_service_access_token to obtain the gtoken.

By default, this method will use a third party’s f_token generation API to obtain the f_token. The API used by default is provided by imink. If you do not trust this URL, you can provide your own URL through the f_token_url argument, or you can replace the f_token generation method used with your own through the use of the set_new_f_token_function method. See the documentation for that method for more information.

Parameters:
session_token : str

The session token.

f_token_url : str

The url to get the user access token from. This defaults to the ftoken generation url provided by imink.

Raises:

NintendoException – In the case that the user’s access token cannot be obtained from the session token, or the user’s information that is returned is invalid.

Returns:

str – The gtoken. This is used to authenticate requests to the Nintendo Switch Online API. This token is valid for 2 hours.