Skip to content

Auto-Login to external websites

External website automatic login allows users who have logged into an external website (for example, Hive Community) to launch the PC game via the Crossplay Launcher and be logged in automatically—without any additional login steps.

Basic flow and implementation

Automatically logging into a game via a crossplay launcher from an external website The basic operation flow is as follows:

  1. Log in to a website that supports 'automatic login from outside the game' such as Hive Community.
  2. After completing the login, issue a token using the Token Issuance API for Automatic Login to External Websites.
  3. Click Run Game on the logged-in website to launch the PC game using the Crossplay Launcher.
  4. Transfer the token issued in 2. to the game via the crossplay launcher running on the PC
  5. Perform automatic login in the game.

Based on the above operation flow, game developers can implement automatic login from an external website by going through the following two steps.

  1. Issue token using web login API
  2. Transfer token to game via Crossplay Launcher

Prerequisites

Before implementing Automatic login via Crossplay Launcher on external website, you must prepare the following.

  • Communication environment that can use Web Login API
  • Game service environment that applies Crossplay Launcher
  • SDK v4 Windows.24.4.0 or higher
    • The automatic login function on external website only works on games that apply SDK Windows v4.24.0.0 or higher.
Note

1. Issue token using web login API

When a user completes logging in to an external website, the developer implements a token issuance required for automatic login to the game from the website the user logged in to.

Request the three APIs provided by the web login API in the following order and receive the web_idp_token token as a response.

  1. Call the login page API request

    • Obtain the state value as a response after the request.
  2. Verify login and retrieve user information API request

    • Obtain the enc_idp value as a response after the request.
    Warning
    • Since enc_idp is a unique value, be careful not to expose it to the outside for security reasons. (When calling the API, server-to-server communication is mandatory.)
  3. Issue token for automatic login from external website API request

    • After the request, a web_idp_token token is issued as a response.
    Note
    • The web_idp_token token is then passed to the game through the Crossplay Launcher.
    • web_idp_token 토큰은 일회성 값으로, 게임 실행 시마다 새로 발급 받아야 합니다.

2. Passing token to the game through the Crossplay Launcher

When a user runs a PC game with the Crossplay Launcher from an external website where the user has logged in, the developer encodes and passes the token web_idp_token issued in the previous step to the game to enable automatic login.

The process of completing automatic login by passing a token to the game is as follows:

  1. Encode the issued token
  2. Configure URI for automatic login including the encoded token
    • Include the encoded token in the game automatic installation URI or game execution URI
  3. Implement JavaScript code including URI for automatic login
  4. When the user runs the PC game with the crossplay launcher, the crossplay launcher and game execution are completed with the URI configured in the JavaScript code, and automatic login is completed
Warning

If you are not logged in to an external website, you cannot pass web_idp_token to the game execution URI, and automatic login is not performed as a result.

Regarding the above process, please refer to the implementation guide for servicing games with the crossplay launcher.

Configure URI for automatic login

The URI for automatic login is configured by including an encoded token in the previously obtained URI depending on whether Crossplay Launcher is installed on the user's PC.

If the Crossplay Launcher is not installed

Include the encoded token in the game auto-installation URI.

If the user clicks the download button for the Crossplay Launcher installer while Crossplay is not installed, the implemented JavaScript code will copy the game auto-installation URI to the user's PC clipboard, and the installed Crossplay Launcher will search for the game auto-installation URI to install and run the game on the PC. Therefore, if the Crossplay Launcher is not installed, you must include the encoded token in the game auto-installation URI that the Crossplay Launcher will search for.

For more information on how to implement when the Crossplay Launcher is not installed, see the Crossplay Launcher Implementation Guide.

Here is an example of a game auto-install URI with an encoded token:

hivelauncher:?app_id={AppID encoding result of the logged-in game}&start_point=9&web_idp_token={web_idp_toekn encoding result} {The entire left URI is sha1 encrypted}

# Example
hivelauncher:?app_id=com.com2us.hivesdk.windows.microsoftstore.global.normal&start_point=9&web_idp_token=eb5605514b44d7ae07f93d3921f202d0a7810eda8c343e42877b23a8a2bb5675462ae3f44c95ec59b0bdaa2ff8b28c4a971acd9439e98ef29f1c7204c230f782 9e93d5396ce59f5eaf3c3ee24a1ccda3e008364b

If the Crossplay Launcher is installed

Include the encoded token in the Game Launch URI.

If the user clicks the Launch Game button while the Crossplay Launcher is installed, the Crossplay Launcher will automatically install and launch the game after launching the Game Launch URI using the JavaScript code you implemented previously. Therefore, if the Crossplay Launcher is installed, you must include the encoded token in the Game Launch URI required to install and launch the game right away.

For more information on how to implement when the Crossplay Launcher is installed, see the Crossplay Launcher Implementation Guide.

Here is an example of a game launch URI with an encoded token:

hivelauncher:?app_id={Encoded AppID of the logged-in game}&start_point=9&web_idp_token={Encoded web_idp_toekn}

# Example
hivelauncher:?app_id=com.com2us.hivesdk.windows.microsoftstore.global.normal&start_point=9&web_idp_token=8549cd7cf3ae7d8cab788abbb3bbf4c2306e38b7d442f02214b492c98f1c05bfff7466a64ad1a3704c962d1aec0268874830eac11455c0c562aed3c0c3505a1f

Crossplay Launcher Execution Javascript Code Implementation

In 'Crossplay Launcher Execution Javascript Code', the Crossplay Launcher and game are executed with the URI configured above. At this time, the web_idp_token token issued by the web login API is passed to the game, so automatic login to the game executed with the Crossplay Launcher can be completed.

Crossplay Launcher Execution Javascript Code Implementation Example is as follows.

     // Set the AppID of the logged-in game.
     var appid = "로그인한 게임의 AppId 세팀함";
     // When installing the launcher, set the URI for running the game.
     var url_play_game = "hivelauncher:?app_id=" + encodeURIComponent(appid) + "&start_point=9";

     // When not installing the launcher, set the URI to copy to the clipboard.
     var url_play_clipbord = "hivelauncher:?app_id=" + encodeURIComponent(appid) + "&start_point=9";

     // Implement the API call logic separately to obtain web_idp_token.
     // At this time, call the internal path with ajax and call the API on the server side. (Required for security)
     // Information about the API can be found in the API call under “1. Issuing tokens using the web login API” above.
         // Set the web_idp_token value obtained as a result of the API call.
     var web_idp_token = "API를 통해 획득 한 토큰 값 세팅함";

     // Apply the web_idp_token to the URI when it is successfully obtained.
     if(web_idp_token != ""){
          // When the launcher is installed, add the token value for automatic login to the URI for running the game.
          url_play_game += ("&web_idp_token=" + encodeURIComponent(web_idp_token));

          // When the launcher is not installed, add the token value for automatic login to the URI to be copied to the clipboard.
          url_play_clipbord += ("&web_idp_token=" + encodeURIComponent(web_idp_token));
          // Separately implement and apply the sha1 encryption function with a space.
          url_play_clipbord += (" " + sha1(url_play_clipbord));
     }

     // Information on this function can be found in the “Implementation Guide for Serving Games with Crossplay Launcher” above.
     window.customProtocolCheck(
          url_play_game, // Pass the URI for running the game set above.
          function (e) {
               // Add processing when Crossplay Launcher execution fails.

               // ex. This is an example of necessary actions.
               // Separately implement and apply the function to copy to the clipboard.
               copyClipboard(url_play_clipbord);.
          },
          function (e) {
               // Add any necessary actions when Crossplay Launcher execution succeeds.
          },
          2500, function (e) {
               // Add processing when there is no response for more than 2500ms after Crossplay Launcher execution request.
     );

For more information on implementing and running Javascript code, see the Crossplay Launcher Implementation Guide.