Skip to content

Android

Hive SDK Android Authentication Configuration Guide

Adding features

You must add the corresponding external library to the module-level build.gradle file. Add only the authentication features you will be using.

The following is an example of adding external libraries to the module-level build.gradle file.

dependencies {
   // Feature-specific settings. Add only the features you are using.
   // AuthV4 Device Management Service
   implementation "com.com2us.android.hive:hive-authv4-device-management"
   // AuthV4 Google In-App Update
   implementation "com.com2us.android.hive:hive-authv4-google-inappupdate"
   // AuthV4 Google reCAPTCHA
   implementation "com.com2us.android.hive:hive-authv4-google-recaptcha"
   // AuthV4 Real Name Verification (China)
   implementation "com.com2us.android.hive:hive-authv4-real-name-verification"
}

Adding IdPs

Add external libraries to the module-level build.gradle file. Add only the IdPs you will be using.

The following is an example of adding external libraries to the module-level build.gradle file. You can use the Guest Login feature without adding any libraries.

dependencies {
    // IdP-specific settings. Add only the IdPs you are using.

    // Apple Login
    implementation "com.com2us.android.hive:hive-authv4-provider-apple-signin"

    // Facebook Login
    implementation "com.com2us.android.hive:hive-authv4-provider-facebook"

    // Google Play Games Login
    // `hive-authv4-provider-google-playgames` includes the `play-service-games-v2` library.
    implementation "com.com2us.android.hive:hive-authv4-provider-google-playgames"

    // Google Login
    // Google Play Games Login and Google Login are different login methods.
    implementation "com.com2us.android.hive:hive-authv4-provider-google-signin"

    // Hive Membership Login
    implementation "com.com2us.android.hive:hive-authv4-provider-hive-membership"

    // Huawei Login
    implementation "com.com2us.android.hive:hive-authv4-provider-huawei"

    // LINE Login
    // To apply the LINE library, minSdkVersion 24 or higher is required.
    implementation "com.com2us.android.hive:hive-authv4-provider-line"

    // QQ Login
    implementation "com.com2us.android.hive:hive-authv4-provider-qq"

    // VK library requires targetSdkVersion 32 or higher.
    implementation "com.com2us.android.hive:hive-authv4-provider-vk"

    // WeChat Login
    implementation "com.com2us.android.hive:hive-authv4-provider-wechat"

    // Weverse Login
    implementation "com.com2us.android.hive:hive-authv4-provider-weverse"
}

Additional settings by IdP

Additional settings are required depending on the IdP.

Google play games sign-in IdP settings

To use Google Play Games Login, configure it as follows.

AndroidManifest.xml settings

This is the configuration for Google Play Services. These are the required values for the Google Play Games Login Setup.

<manifest>
    <application>
    <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/game_services_project_id"/>
    </application>
</manifest>

hive_config.xml settings

In hive_config.xml, set playAppId and serverClientId in the <google> tag within the <providers> tag.

Facebook IdP settings

To use Facebook Login, make the necessary settings in AndroidManifest.xml.

First, configure the FacebookContentProvider for sharing links, images, or videos from your app. In the android:authorities attribute, add the Facebook AppID to com.facebook.app.FacebookContentProvider.

Example: When the Facebook AppID is 123456789

<provider android:authorities="com.facebook.app.FacebookContentProvider123456789" />

Add the settings for Facebook AppId and client token settings (required for Facebook v13 or higher).

Example: When the Facebook AppID is 123456789

<meta-data
    android:name="com.facebook.sdk.ApplicationId"
    android:value="fb123456789"/>

Example: When the Facebook Client Token is 123456789

<meta-data
    android:name="com.facebook.sdk.ClientToken"
    android:value="fb123456789"/>
Note

Facebook AppId and client token can also be set in the string.xml file. In this case, the fb prefix is not required when setting android:value. For more information, see here.

QQ/Wechat IdP settings

If you support QQ or WeChat IdP, apply the following content in addition.


Set the dependency on the libs folder in the module-level build.gradle file.

dependencies {
   implementation fileTree(include: ['*.jar'], dir: 'libs')
   implementation fileTree(include: ['*.aar'], dir: 'libs')
}

Add the external library (.aar/.jar) in the libs folder at the module level to the Hive SDK distribution version. The list of external libraries included in the distribution version is as follows.

  • mid-sdk-2.10.jar (Add this file when supporting QQ IdP login)
  • mta-sdk-2.0.0.jar (Add this file when supporting QQ or Wechat IdP login)
  • open_sdk_3.5.4.11_r3f56456_lite.jar (Add this file when supporting QQ IdP login)

VK IdP settings

  • Set the app id issued from the VK console in the /res/values/strings.xml file.
<integer name="com_vk_sdk_AppId">your_app_id</integer>

Huawei IdP settings

  1. Add agconnect-services.json
    • Add the agconnect-services.json file downloaded from the Huawei console to the Project folder.
  2. Project - build.gradle file settings
    • Add the AppGallery Connect plugin and Maven address.
      buildscript {
          repositories {
              google()
              jcenter()
              // Huawei HMS Core SDK.
              maven {url 'https://developer.huawei.com/repo/'}
          }
          dependencies {
              ...
              // Huawei AppGallery Connect plugin
              classpath 'com.huawei.agconnect:agcp:1.9.1.301'
          }
      }
      allprojects {
          repositories {
              google()
              jcenter()
              /// Huawei HMS Core SDK.
              maven {url 'https://developer.huawei.com/repo/'}
          }
      }  
      
  3. App - build.gradle file settings
    • Add Huawei authentication library and plugin.
      dependencies {
          // Huawei Dependency
          implementation "com.com2us.android.hive:hive-authv4-provider-huawei" // Huawei authentication
      }
      apply plugin: 'com.huawei.agconnect'