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 inloginType
parameter.- If you set the different login type from the value returned by Hive and implement
login()
method, Hive returns an error.
- If you set the different login type from the value returned by Hive and implement
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.
API Reference: hive.Auth.getLoginType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// Search login type available to perform. LoginType loginType = Auth.getLoginType(); switch(loginType) { case LoginType.GUEST: // Available to perform guest login. break; case LoginType.ACCOUNT: // Available to perform Hive login. break; case LoginType.SELECT: // Available to perform login with user-selected account. break; case LoginType.AUTO: // Available to perform auto login. break; } |
API Reference: Auth::getLoginType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Search login type available to perform. LoginType loginType = Auth::getLoginType(); switch(loginType) { case LoginType::GUEST: // Available to perform guest login. break; case LoginType::ACCOUNT: // Available to perform Hive login. break; case LoginType::SELECT: // Available to perform login with user-selected account. break; case LoginType::AUTO: // Available to perform auto login. break; } |
API Reference: com.hive.Auth.getLoginType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Search login type available to perform. LoginType loginType = com.hive.Auth.getLoginType(); switch (loginType) { case GUEST: // Available to perform guest login. break; case ACCOUNT: // Available to perform Hive login. break; case SELECT: // Available to perform login with user-selected account. break; case AUTO: // Available to perform auto login. break; } |
API Reference: HIVEAuth:getLoginType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Search login type available to perform. HIVELoginType loginType = [HIVEAuth getLoginType]; switch (loginType) { case kHIVELoginTypeGUEST: // Available to perform guest login. break; case kHIVELoginTypeACCOUNT: // Available to perform Hive login. break; case kHIVELoginTypeSELECT: // Available to perform login with user-selected account. break; case kHIVELoginTypeAUTO: // Available to perform auto login. break; } |
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.
API Reference: hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Set login type as guest login. LoginType loginType = LoginType.GUEST; // Callback handler managing the result of performing login. public void onAuthLoginCB(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSucces){ // Success in API call. } } // Request for guest login. hive.Auth.login(loginType, onAuthLoginCB); |
API Reference: Auth::login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set the login type as guest login. LoginType loginType = LoginType::GUEST; // Request for guest login. Auth::login(loginType, [=](ResultAPI result,LoginType loginType, Account currentAccount, Account usedAccount){ // Callback function managing the result of performing login. if(result.isSuccess()){ // Success in API call. } } ); |
API Reference: com.hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set the login type as guest login. LoginType loginType = LoginType.GUEST; // Request for guest login. Auth.login(loginType, new Auth.AuthLoginListener() { // Callback listener managing the result of performing login. @Override public void onAuthLogin(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: HIVEAuth:login
1 2 3 4 5 6 7 8 9 10 11 |
// Set the login type as guest login. HIVELoginType loginType = kHIVELoginTypeGUEST; // Request for guest login. [HIVEAuth login:loginType handler:^(HIVEResultAPI* result, HIVELoginType loginType, HIVEAccount *currentAccount, HIVEAccount *usedAccount) { // // Callback handler managing the result of performing login. if(result.isSuccess){ // Success in API call. } }]; |
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.
API Reference: hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set the login type as Hive membership login. LoginType loginType = LoginType.ACCOUNT; // Callback handler managing the result of performing login. public void onAuthLoginCB(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Save the received user data on game server. } } // Request for Hive membership login. hive.Auth.login(loginType, onAuthLoginCB); |
API Reference: Auth::login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Set the login type as Hive membership login. LoginType loginType = LoginType::ACCOUNT; // Request for Hive membership login. Auth::login(loginType, [=](ResultAPI result,LoginType loginType, Account currentAccount, Account usedAccount) { // Callback function managing the result of performing login. if(result.isSuccess()){ // Save the received user data on game server. } } ); |
API Reference: com.hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set the login type as Hive membership login. LoginType loginType = LoginType.ACCOUNT; // Request for Hive membership login. Auth.login(loginType, new Auth.AuthLoginListener() { // Callback listener managing the result of performing login. @Override public void onAuthLogin(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Save the received user data on game server. } } } }); |
API Reference: HIVEAuth:login
1 2 3 4 5 6 7 8 9 10 11 |
// Set the login type as Hive membership login. HIVELoginType loginType = kHIVELoginTypeACCOUNT; // Request for Hive membership login. [HIVEAuth login:loginType handler:^(HIVEResultAPI* result, HIVELoginType loginType, HIVEAccount *currentAccount, HIVEAccount *usedAccount) { // Callback handler managing the result of performing login. if(result.isSuccess){ // Save the received user data on game server. } }]; |
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 SELECTcurrentAccount
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.
API Reference: hive.Auth.bindLogin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Current or used VID. String bindVid = "123456789"; // Callback handler managing the result of performing login. public void onAuthBindLoginCB(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Success in API call. } } // Sync VID of the selected account with user’s Hive account. hive.Auth.bindLogin(bindVid, onAuthBindLoginCB); |
API Reference: Auth::bindLogin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Current or used VID. std::string bindVid = "123456789"; // Sync VID of the selected account with user's Hive account. Auth::bindLogin(bindVid, [=](ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount){ // Callback function managing the result of performing login. if(result.isSuccess()){ // Success in API call. } }); |
API Reference: com.hive.Auth.bindLogin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Current or used VID. String bindVid = "123456789"; // Sync VID of the selected account with user's Hive account. Auth.bindLogin(bindVid, new Auth.AuthLoginListener() { // Callback listener managing the result of performing login. @Override public void onAuthLogin(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: HIVEAuth:bindLogin
1 2 3 4 5 6 7 8 9 10 11 |
// Current or used VID. NSString *bindVid = "123456789" // Sync VID of the selected account with user's Hive account. [HIVEAuth bindLogin:bindVid handler:^(HIVEResultAPI *result, HIVELoginType loginType, HIVEAccount *currentAccount, HIVEAccount *usedAccount) { // Callback handler managing the result of performing login. if(result.isSuccess()){ // Success in API call. } }]; |
Handling Account Selection
Followings inform you how to respond to account selection by using the account selection UI that Hive provides.
- 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 thevid
ofcurrentAccount
and thevid
ofusedAccount
in the global variable.
API Reference: hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
String currentVid = ""; String usedVid = ""; // Set the login type as Hive membership login. LoginType loginType = LoginType.ACCOUNT; // Callback handler managing the result of performing login. public void onAuthLoginCB(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // If parameter format is loginType.SELECT, implement the showLoginSelection() method for user to select the account to log in. // Save the VID to implement showLoginSelection() method. if(loginType == LoginType.SELECT) { currentVid = currentAccount.vid; usedVid = usedAccount.vid; } } } // Request for Hive membership login. hive.Auth.login(loginType, onAuthLoginCB); |
API Reference: Auth::login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
string currentVid = ""; string usedVid = ""; // Set the login type as Hive membership login. LoginType loginType = LoginType::ACCOUNT; // Request for Hive membership login. Auth::login(loginType, [=](ResultAPI result,LoginType loginType, Account currentAccount, Account usedAccount) { // Callback function managing the result of performing login. if(result.isSuccess()){ // If parameter format is loginType.SELECT, implement the showLoginSelection() method for user to select the account to log in. // Save the VID to implement showLoginSelection() method. if(loginType == LoginType::SELECT) { currentVid = current.vid; usedVid = used.vid; } } } ); |
API Reference: com.hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
String currentVid = ""; String usedVid = ""; // Set the login type as Hive membership login. LoginType loginType = LoginType.ACCOUNT; // Request for Hive membership login. Auth.login(loginType, new Auth.AuthLoginListener() { // Callback listener managing the result of performing login. @Override public void onAuthLogin(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // If parameter format is loginType.SELECT, implement the showLoginSelection() method for user to select the account to log in. // Save the VID to implement showLoginSelection() method. if(loginType == LoginType.SELECT) { currentVid = currentAccount.vid; usedVid = usedAccount.vid; } } } }); |
API Reference: HIVEAuth:login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
NSString* currentVid = @""; NSString* usedVid = @""; // Set the login type as Hive membership login. HIVELoginType loginType = kHIVELoginTypeACCOUNT; // Request for Hive membership login. [HIVEAuth login:loginType handler:^(HIVEResultAPI* result, HIVELoginType loginType, HIVEAccount *currentAccount, HIVEAccount *usedAccount) { // Callback handler managing the result of performing login. if(result.isSuccess){ // If parameter format is loginType.SELECT, implement the showLoginSelection() method for user to select the account to log in. // Save the VID to implement showLoginSelection() method. if(loginType == kHIVELoginTypeSELECT) { currentVid = currentAccount.vid; usedVid = usedAccount.vid; } } }]; |
- 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.
1234{"vid": <User vid, String>"data": {"Name": <User name in game, String>, "Level": <User level in game, Number>}}
- Implement callback function of
showLoginSelection()
method. - 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.
API Reference: hive.Auth.showLoginSelection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
String currentVid = ""; String usedVid = ""; /* 1. Use the following sample code for Hive membership login. */ // 2. The information of guest account which is logged in on user device. JSONObject currentVidData = new JSONObject(); currentVidData.AddField("vid", currentVid); JSONObject currendVidGameData = new JSONObject(); currentVidGameData.AddField("Name", "currentName"); currentVidGameData.AddField("Level", 10); currentVidData.AddField("data", currentVidGameData); // 2. The information of Hive membership account which user input. JSONObject usedVidData = new JSONObject(); usedVidData.AddField("vid", usedVid); JSONObject usedVidGameData = new JSONObject(); usedVidGameData.AddField("Name", "usedName"); usedVidGameData.AddField("Level", 11); usedVidData.AddField("data", usedVidGameData); // 3. Callback handler managing the result of implementing account selection UI. public void onAuthSelectLoginCB(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Success in API call. } } // 4. Implement the account selection UI. Auth.showLoginSelection (currentVidData, usedVidData, onAuthSelectLoginCB); |
API Reference: Auth::showLoginSelection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
string currentVid = ""; string usedVid = ""; /* 1. Use the following sample code for Hive membership login. */ picojson::object currentVidData; currentVidData["vid"] = picojson::value(currentVid); // 2. The information of guest account which is logged in on user device. picojson::object currentVidGameData; currentVidGameData["Name"] = picojson::value("CurrentName"); currentVidGameData["Level"] = picojson::value((double)10); currentVidData["data"] = picojson::value(currentVidGameData); picojson::object usedVidData; usedVidData["vid"] = picojson::value(usedVid); // 2. The information of Hive membership account which user input. picojson::object usedVidGameData; usedVidGameData["Name"] = picojson::value("usedName"); usedVidGameData["Level"] = picojson::value((double)11); usedVidData["data"] = picojson::value(usedVidGameData); // 4. Implement the account selection UI. Auth::showLoginSelection(currentVidData, usedVidData, [=](ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { // 3. Callback function managing the result of implementing account selection UI. if(result.isSuccess()){ // Success in API call. } } ); |
API Reference: com.hive.Auth.showLoginSelection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
String currentVid = ""; String usedVid = ""; /* 1. Use the following sample code for Hive membership login. */ // 2. The information of guest account which is logged in on user device. Map<String, Object> currentVidData = new HashMap<>(); currentVidData.put("vid", currentVid); Map<String, Object> currentVidGameData = new HashMap<>(); currentVidGameData.put("Name", "CurrentName"); currentVidGameData.put("Level", 10); currentVidData.put("data", currentVidGameData); // 2. The information of Hive membership account which user input. Map<String, Object> usedVidData = new HashMap<>(); usedVidData.put("vid", usedVid); Map<String, Object> usedVidGameData = new HashMap<>(); usedVidGameData.put("Name", "UsedName"); usedVidGameData.put("Level", 11); usedVidData.put("data", usedVidGameData); // 4. Implement the account selection UI. Auth.showLoginSelection(currentVidData, usedVidData, new com.hive.Auth.AuthLoginListener() { // 3. Callback listener managing the result of implementing account selection UI. @Override public void onAuthLogin(final ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: HIVEAuth:showLoginSelection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
NSString* currentVid = @""; NSString* usedVid = @""; /* 1. Use the following sample code for Hive membership login. */ // 2. The information of guest account which is logged in on user device. NSDictionary* currentVidData = @{@"data" : @{@"Name" : @"CurrentName", @"Level" : @"10"}, @"vid" : currentVid}; // 2. The information of Hive membership account which user input. NSDictionary* selectVidData = @{@"data" : @{@"Name" : @"UsedName", @"Level" : @"11"}, @"vid" : usedVid}; // 4. Implement the account selection UI. [HIVEAuth showLoginSelection:currentVidData usedData:selectVidData handler:^(HIVEResultAPI *result, HIVELoginType loginType, HIVEAccount *currentAccount, HIVEAccount *usedAccount) { // 3. Callback handler managing the result of implementing account selection UI. if(result.isSuccess){ // Success in API call. } }]; |
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.
API Reference: hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Set the login type as auto login. LoginType loginType = LoginType.AUTO; // Callback handler managing the result of performing login. public void onAuthLoginCB(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSucces){ //Success in API call. } } // Request for auto login. hive.Auth.login(loginType, onAuthLoginCB); |
API Reference: Auth::login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set the login type as auto login. LoginType loginType = LoginType::AUTO; // Request for auto login. Auth::login(loginType, [=](ResultAPI result,LoginType loginType, Account current, Account used){ // Callback function managing the result of performing login. if(result.isSuccess()){ // Success in API call. } } ); |
API Reference: com.hive.Auth.login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set the login type as auto login. LoginType loginType = LoginType.AUTO; // Request for auto login. Auth.login(loginType, new Auth.AuthLoginListener() { // Callback listener managing the result of performing login. @Override public void onAuthLogin(ResultAPI result, LoginType loginType, Account currentAccount, Account usedAccount) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: HIVEAuth:login
1 2 3 4 5 6 7 8 9 10 11 |
// Set the login type as auto login. HIVELoginType loginType = kHIVELoginTypeAUTO; // Request for auto login. [HIVEAuth login:loginType handler:^(HIVEResultAPI* result, HIVELoginType loginType, HIVEAccount *currentAccount, HIVEAccount *usedAccount) { // Callback handler managing the result of performing login. if(result.isSuccess){ // Success in API call. } }]; |
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.
API Reference: hive.Auth.logout
1 2 3 4 5 6 7 8 9 10 |
// Callback handler managing the result of Hive logout. public void onAuthLogoutCB(ResultAPI result) { if(result.isSuccess()){ // Success in API call. } } // Request to log out Hive. hive.Auth.logout(onAuthLogoutCB); |
API Reference: Auth::logout
1 2 3 4 5 6 7 8 |
// Request to log out Hive. Auth::logout([=](ResultAPI result) { // Callback function managing the result of Hive logout. if(result.isSuccess()){ // Success in API call. } } ); |
API Reference: com.hive.Auth.logout
1 2 3 4 5 6 7 8 9 10 |
// Request to log out Hive. Auth.logout(new Auth.AuthLogoutListener() { // Callback listener managing the result of Hive logout. @Override public void onAuthLogout(ResultAPI result) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: HIVEAuth:logout
1 2 3 4 5 6 7 |
// Request to log out Hive. [HIVEAuth logout:^(HIVEResultAPI *result) { // Callback handler managing the result of Hive logout. if(result.isSuccess){ // Success in API call. } }]; |