Once the game is running, users must log in to the Hive server, regardless of whether or not they are a member, and you should proceed their log-in with the login type that Hive returns to the user.

Search the available login type and click below links for more information about how to sign in for each login type:

Searching for Login Type

In addition to receiving the login type that Hive sends as the result of initialization, you can query the user’s possible login types by using the API directly.

Type Description

The login types used in Hive authentication are GUEST, ACCOUNT, SELECT, and AUTO. Login type and the meaning of each type are as follows;

  • GUEST: Users who has no login history with Hive account, and no session key exists as well.
  • ACCOUNT: Users who has login history with Hive account, but no session key exists.
  • SELECT: Users who has login history with two or more accounts, and who are required to select one account due to conflicts. The result of type search or Hive initialization is not returned.
  • AUTO: Users who has login history with guest or Hive account, and session key exists on user device.

What to do with the information of login type

  • Provide a login button or not as following description depending on the login type.
    • GUEST: Display the game without the process of Hive login or provide a login button to make guest users sign in as Hive members
    • ACCOUNT: Provide a login button
    • SELECT: Display a selection window for user to select one among the accounts used for game play
    • AUTO: User device has session key, so the user doesn’t have to sign in manually. Do not provide a login button
  • When logging in, implement login() method by setting the login type in loginType parameter.
    • If you set the different login type from the value returned by Hive and implement login() method, Hive returns an error.

Implementing Login Type Search

Implement getLoginType() method in the Auth class to search the available login type for users.
Followings are sample codes to search login type.

Unity®

API Reference: hive.Auth.getLoginType

C++

API Reference: Auth::getLoginType

Android

API Reference: com.hive.Auth.getLoginType

iOS

API Reference: HIVEAuth:getLoginType

Guest Login

Hive supports guest login service for users to play the game without signing up Hive. If Hive has returned the GUEST login type as a result of Hive initialization or calling getLoginType() method, it means the user did not sign in the Hive server as a member of Hive via the game. Even when the player has signed in the game as a Hive member on the previously used device, or when DID is newly issued due to reinstallation, Hive still returns GUEST as the login type.

When a user logs in as a guest, Hive issues a unique user ID (VID) in the game to the user. This VID is valid until the game data or the app is deleted. After signing in as a guest for the first time, the user must sign in the Hive server with the login type, AUTO, unless the user logs in as a Hive member.

Guest Login Policy

When user signs in as a guest, ensure to comply with the following policy:

Build a game available for guest users and Hive members equally

If you log in as a guest, you will not be able to use the social media features that your account is required, but you can use most of Hive’s features. Therefore, make sure to make your game available both a guest and a member to play in a same way. For example, guest user should be available to pay and purchase items in the game.

Do not allow guest users to sign out

If a user logs in as a guest then logs out, there is no way to find the VID that track the user information. It becomes difficult to respond when the user logs out and then inquires about when he / she is logged in as a guest. for example, questions about payment, etc. Therefore, do not provide a logout button to prevent users from signing out when their state is the guest.

Guest Login Policy with Chinese IP

If users access the game with Chinese IP, only authorized members can charge game money or purchase items (started from May 1, 2017). Therefore, when the users with Chinese IP firstly access the game, you should display Hive login page without Guest Login button rather than automatic login procedure. If a user joined as a guest member before the policy is in effect, it is necessary to recommend or force a conversion to a Hive member.

However, if you block all guests regardless of the unverified enforcement of laws, it may cause churn. Therefore, allow the existing guest users to autonomously follow the policies of Com2uS and Com2uS Holdings, but it is necessary to forcefully switch them into Hive members when sanctions are imposed by Chinese authorities.

Use the Hive time zone service to determine if the user is accessing from China IP.

An example to block new guest users with Chinese IP

  • Excluding ‘Guest Login’ button on the loading page of the game
  • Excluding the process of automatic guest login when user starts the game for the first time

An example to block existing guest users with Chinese IP
Provide a recommendation popup to sign up Hive as follows. If you recommend Hive sign-up, display Sign up or Next time button in the popup; if you force, display Sign up or End game button in the popup.

  • Displaying a popup for Hive sign-up when user access the in-game shop
  • Displaying a popup for Hive sign-up on the game lobby

Logging in as a Guest

Implement login() method in the Auth class for users to sign in as guests. After successful login, Hive returns currentAccount containing user identifier, and The value of usedAccount is returned as null. Make sure to save the session key of users on game server when you receive the user data.
Followings are sample codes to sign in as a guest.

Unity®

API Reference: hive.Auth.login

C++

API Reference: Auth::login

Android

API Reference: com.hive.Auth.login

iOS

API Reference: HIVEAuth:login

Hive Login

A user who signs up Hive and has Hive account is called a Hive member, and the sign-in of the member is called Hive login. When a user signs up Hive and becomes a member, Hive issues uid, a unique user ID in Hive to the user.

When a Hive member plays a game for the first time without any history as a guest on the user device, Hive issues a VID, a unique user ID in the game to the member player, and connects the VID with user’s uid. If the VID for the same game on the user device is already issued, which means, a history of guest login exists on the device, Hive connects the issued VID with the member’s uid.

When a member logs in again after logout, UID or VID are not newly issued, but the existing UID and VID help the user to sign in.

Can a user logged in as a guest sign in as a member of the game?
A user logged in as a guest can sign in as a member while playing the game. To do that, you need to provide a button or link to log in to Hive in the game.

Signing in as a Member (Hive Login)

Implement login() method in the Auth class to make users log in as a Hive member. Depending on whether the login session as Hive member is recorded or not, Hive performs one of two options as follows:

  • Login record as Hive member: Hive will make users automatically sign in
  • No login record as Hive member: Hive will display sign-in page to receive user ID and password required

If Hive successfully performs the Hive member login, it will return the user identifier contained within currentAccount, the third parameter of callback function delivered to the login() method. Once you receive the user data, store the user’s login session key on the game server.

Followings are sample codes how users sign in to Hive as members.

Unity®

API Reference: hive.Auth.login

C++

API Reference: Auth::login

Android

API Reference: com.hive.Auth.login

iOS

API Reference: HIVEAuth:login

Login with Selected Account

Choosing an account means that the sign-in record of more than one account exists, so user need to selects which account to sign in to the game. If a user device has a history of game play and VID, and user attempts to sign in with Hive account on the same device, conflicts may occur in case the VID is synced with the Hive account.

The game should know whether the user should choose an account, and if it is necessary to select an account, [tooltips keyword=”Account Selection UI” content=”“]. Both are provided by Hive.

When and how do I know if account selection is required?
If account selection is needed, Hive notifies the game when you try to make a user sign in as a Hive member. That is, when you implement the login() method in the Auth class after setting loginType as ACCOUNT, the following data is returned as a result.

  • loginType parameter: Enumerated type relevant to SELECT
  • currentAccount parameter: The account data of logged in as a guest on the device(Account class)
  • usedAccount parameter: The account data of members (Account class)

How can I provide an account selection UI? Should I use the Hive UI?
Implement showLoginSelection() method in the Auth class to display the account selection UI provided by Hive.

If you do not want to use the account selection UI provided by Hive, perform the step 1 in Handling Account Selection, and then customize the UI available for user to choose an account. After user select the account, make sure to call bindLogin() in the Auth class to sync the VID of selected account with Hive account.

Unity®

API Reference: hive.Auth.bindLogin

C++

API Reference: Auth::bindLogin

Android

API Reference: com.hive.Auth.bindLogin

iOS

API Reference: HIVEAuth:bindLogin

Handling Account Selection

Followings inform you how to respond to account selection by using the account selection UI that Hive provides.

  1. Make sure to check whether the loginType value you received as a result of the login is an enumerated type relevant to SELECT. If it is SELECT, store the vid of currentAccount and the vid of usedAccount in the global variable.
Unity®

API Reference: hive.Auth.login

C++

API Reference: Auth::login

Android

API Reference: com.hive.Auth.login

iOS

API Reference: HIVEAuth:login

  1. Define the parameter of showLoginSelection() method as follows.
    • currentVidData: The information of guest account signed in the device (JSON format)
    • usedVidData: The information of account which user tried to sign in (JSON format)

    An example of account data schema with JSON format: vid and data field are essential. You can add user data freely in data object.

  1. Implement callback function of showLoginSelection() method.
  2. Implement showLoginSelection() method to display an account selection popup that Hive provides.

Followings are sample codes which implements step 2 to 4 of above guide.

Unity®

API Reference: hive.Auth.showLoginSelection

C++

API Reference: Auth::showLoginSelection

Android

API Reference: com.hive.Auth.showLoginSelection

iOS

API Reference: HIVEAuth:showLoginSelection

Automatic Login

If a user once signed in Hive server as a guest or Hive member, the session key issued by Hive will remain on the user’s device.

If Hive returns the login type as AUTO after initializing Hive or calling getLoginType() method, automatic login is available. In this circumstance, If you call the login API (login() method in the Auth class) with the login type parameter set to AUTO, Hive will automatically login. The automatic login depends on the session key; a guest session key for the guest login, a Hive session key for the Hive login.

Expired session key
If user’s session key is expired, Hive returns errorCode = INVALID_SESSION(-9), Code = AuthInvalidAccountSession(-1100016) as a result of Result API. Automatic login is unavailable in this circumstance, so provide a login button for user to sign in manually.

Followings are sample codes to sign in automatically.

Unity®

API Reference: hive.Auth.login

C++

API Reference: Auth::login

Android

API Reference: com.hive.Auth.login

iOS

API Reference: HIVEAuth:login

Reference: Account Class

Name Type Description
vid String Unique user ID currently using in the game

Tip: Use VID as a primary key (PK) of user data on user database in the game server

uid String Unique user ID in Hive. Guest login returns null
did String Device ID

Tip: Use DID as a sub key on user database in the game server

accessToken String A unique session key issued by Hive server to verify user’s login

Verifying Session Key for Authentication

Hive provides a session key validation API to prevent duplicate use of games on two or more devices at the same time. Only the most recently logged in session key for each VID is valid and the previously issued session key is invalid.

To verify the session key, game server requests the session key by VID to Hive server. When game server receives the key, compare the key with the saved one at the time of login. After that, disconnect the invalid session. Then you can prevent the duplicated use.

Verifying session API which is a part of server API, is requested from game server to Hive server. For more information about this API, see Verifying Authentication v1 Session Key.

Logout

Implement logout() method in the Auth class to support the sign-out of membership users. Do not provide sign-out function to guest users. For more information about the unavailable reasons, see Guest Login Policy.

Followings are sample codes for membership user’s sign-out.

Unity®

API Reference: hive.Auth.logout

C++

API Reference: Auth::logout

Android

API Reference: com.hive.Auth.logout

iOS

API Reference: HIVEAuth:logout