Methods

These are the methods provided by the Wepin Android Login Library.

Methods can be used after initialization of Wepin Login Library.

loginWithOauthProvider

wepinLogin.loginWithOauthProvider(params)

An in-app browser will open and proceed to log in to the OAuth provider. To retrieve Firebase login information, you need to execute either the loginWithIdToken() or loginWithAccessToken() method.

Parameters

  • params <LoginOauth2Params>

    • provider <'google'|'naver'|'discord'|'apple'> - Provider for login

    • clientId <String>

Returns

  • CompletableFuture<LoginOauthResult>

    • provider <String> - login provider

    • token <String> - accessToken (if provider is "naver" or "discord") or idToken (if provider is "google" or "apple")

    • type <OauthTokenType> - type of token

Exception

Example

LoginOauth2Params loginOption = new LoginOauth2Params(
                    provider = "discord",
                    clientId = getString(R.string.default_discord_client_id),
                  )
CompletableFuture<LoginOauthResult> res = wepinLogin.loginWithOauthProvider(loginOption);
res.whenComplete((loginResponse, error) -> {
    if (error == null) {
        System.out.println("loginResponse: " + loginResponse);
        String privateKey = "private key for wepin id/access Token"
        // token sign 
        String sign = wepinLogin.getSignForLogin(loginResponse.token, privateKey)
        //call loginWithIdToken() or loginWithAccessToken()
    } else {
        // render error UI
        System.out.println("login error" + error.getMessage())
    }
});

signUpWithEmailAndPassword

wepinLogin.signUpWithEmailAndPassword(params)

This method signs up on Wepin Firebase with your email and password. It returns Firebase login information upon successful signup.

Parameters

  • params <LoginWithEmailParams>

    • email <String> - User email

    • password <String> - User password

    • locale <String> - optional Language for the verification email (default value: "en")

Returns

  • CompletableFuture<LoginResult>

    • provider <Providers.EMAIL>

    • token <FBToken>

      • idToken <String> - wepin firebase idToken

      • refreshToken ` - wepin firebase refreshToken

Exception

Example

LoginWithEmailParams loginOption = new LoginWithEmailParams(
                    "abc@defg.com",
                    "abcdef123&",
                    "ko"
                  )
CompletableFuture<LoginResult> res = wepinLogin.signUpWithEmailAndPassword(loginOption);
res.whenComplete((loginResponse, error) -> {
    if (error == null) {
        System.out.println("loginResponse: " + infResponse);
    } else {
        // render error UI
        System.out.println("login error" + error.getMessage())
    }
});

loginWithEmailAndPassword

wepinLogin.loginWithEmailAndPassword(params)

This method logs in to the Wepin Firebase using your email and password. It returns Firebase login information upon successful login.

Parameters

  • params <LoginWithEmailParams>

    • email <String> - User email

    • password <String> - User password

Returns

  • CompletableFuture<LoginResult>

    • provider <Providers.EMAIL>

    • token <FBToken>

      • idToken <String> - wepin firebase idToken

      • refreshToken ` - wepin firebase refreshToken

Exception

Example

LoginWithEmailParams loginOption = new LoginWithEmailParams(
                    "abc@defg.com",
                    "abcdef123&",
                  )
CompletableFuture<LoginResult> res = wepinLogin.loginWithEmailAndPassword(loginOption);
res.whenComplete((loginResponse, error) -> {
    if (error == null) {
        System.out.println("loginResponse: " + infResponse);
    } else {
        // render error UI
        System.out.println("login error" + error.getMessage())
    }
});

loginWithIdToken

wepinLogin.loginWithIdToken(params)

This method logs in to the Wepin Firebase using an external ID token. It returns Firebase login information upon successful login.

Parameters

  • params <LoginOauthIdTokenRequest>

    • token <String> - ID token value to be used for login

    • sign <String> - Signature value for the token provided as the first parameter.(Returned value of getSignForLogin())

Returns

  • CompletableFuture<LoginResult>

    • provider <Providers.EXTERNAL_TOKEN>

    • token <FBToken>

      • idToken <String> - wepin firebase idToken

      • refreshToken ` - wepin firebase refreshToken

Exception

Example

String token = "eyJHGciO....adQssw5c"
String sign = "9753d4dc...c63466b9"
LoginWithEmailParams loginOption = new LoginOauthIdTokenRequest(token, sign)
CompletableFuture<LoginResult> res = wepinLogin.loginWithIdToken(loginOption);
res.whenComplete((loginResponse, error) -> {
    if (error == null) {
        System.out.println("loginResponse: " + infResponse);
    } else {
        // render error UI
        System.out.println("login error" + error.getMessage())
    }
});

loginWithAccessToken

wepinLogin.loginWithAccessToken(params)

This method logs in to the Wepin Firebase using an external access token. It returns Firebase login information upon successful login.

Parameters

  • params <LoginOauthAccessTokenRequest>

    • provider <"naver"|"discord"> - Provider that issued the access token

    • accessToken <String> - Access token value to be used for login

    • sign <String> - Signature value for the token provided as the first parameter. (Returned value of getSignForLogin())

Returns

  • CompletableFuture<LoginResult>

    • provider <Providers.EXTERNAL_TOKEN>

    • token <FBToken>

      • idToken <String> - wepin firebase idToken

      • refreshToken ` - wepin firebase refreshToken

Exception

Example

String accessToken = "eyJHGciO....adQssw5c"
String sign = "9753d4dc...c63466b9"
LoginOauthAccessTokenRequest loginOption = new LoginOauthAccessTokenRequest("discord", accessToken, sign)
CompletableFuture<LoginResult> res = wepinLogin.loginWithAccessToken(loginOption);
res.whenComplete((loginResponse, error) -> {
    if (error == null) {
        System.out.println("loginResponse: " + infResponse);
    } else {
        // render error UI
        System.out.println("login error" + error.getMessage())
    }
});

getRefreshFirebaseToken

wepinLogin.getRefreshFirebaseToken()

This method retrieves the current firebase token's information from the Wepin.

Parameters

  • void

Returns

  • CompletableFuture<LoginResult>

    • provider <Providers>

    • token <FBToken>

      • idToken <String> - wepin firebase idToken

      • refreshToken ` - wepin firebase refreshToken

Exception

Example

CompletableFuture<WepinUser> res = wepinLogin.getRefreshFirebaseToken();
res.whenComplete((firebaseResponse, error) -> {
  if (error == null) {
      System.out.println("firebaseResponse: " + firebaseResponse);
      // render logged in UI
        println(firebaseResponse)
  } else {
      // render error UI
      System.out.println("login error: " + error.getMessage());
  }
});

loginWepin

wepinLogin.loginWepin(param)

This method logs the user into the Wepin application using the specified provider and token.

Parameters

The parameters should utilize the return values from the loginWithEmailAndPassword(), loginWithIdToken(), and loginWithAccessToken() methods within this module.

  • <LoginResult>

    • provider <Providers>

    • token <FBToken>

      • idToken <String> - Wepin Firebase idToken

      • refreshToken<String> - Wepin Firebase refreshToken

Returns

  • CompletableFuture<WepinUser> - A promise that resolves to an object containing the user's login status and information. The object includes:

    • status <'success'|'fail'> - The login status.

    • userInfo <UserInfo> optional - The user's information, including:

      • userId <String> - The user's ID.

      • email <String> - The user's email.

      • provider <'google'|'apple'|'naver'|'discord'|'email'|'external_token'> - The login provider.

      • use2FA <Boolean> - Whether the user uses two-factor authentication.

    • walletId <String> = The user's wallet ID.

    • userStatus: <UserStatus> - The user's status of wepin login. including:

      • loginStats: <'complete' | 'pinRequired' | 'registerRequired'> - If the user's loginStatus value is not complete, it must be registered in the wepin.

      • pinRequired?:

    • token: <Token> - The user's token of wepin.

      • accessToken: <String>

      • refreshToken <String>

Exception

Example

String accessToken = "eyJHGciO....adQssw5c"
String sign = "9753d4dc...c63466b9"
LoginOauthAccessTokenRequest loginOption = new LoginOauthAccessTokenRequest("discord", accessToken, sign)
CompletableFuture<LoginResult> res = wepinLogin.loginWithAccessToken(loginOption);
res.whenComplete((loginResponse, error) -> {
  if (error == null) {
      System.out.println("loginResponse: " + loginResponse);
      CompletableFuture<LoginResult> resWepin = wepinLogin.loginWepin(loginResponse);
      resWepin.whenComplete((loginWepinResponse, error) -> {
        if (error == null) {
            System.out.println("loginWepinResponse: " + loginWepinResponse);
            if(loginWepinResponse.loginStatus === WepinLoginStatus.PIN_REQUIRED||loginWepinResponse.loginStatus === WepinLoginStatus.REGISTER_REQUIRED) {
                // wepin registration
            }else {
              // render logged in UI
            }                
        } else {
            // render error UI
            System.out.println("login error" + error.getMessage())
        }
      })
  } else {
      // render error UI
      System.out.println("login error" + error.getMessage())
}
});

getCurrentWepinUser

wepinLogin.getCurrentWepinUser()

This method retrieves the current logged-in user's information from the Wepin.

Parameters

  • void

Returns

  • CompletableFuture<WepinUser> - A promise that resolves to an object containing the user's login status and information. The object includes:

    • status <'success'|'fail'> - The login status.

    • userInfo <UserInfo> optional - The user's information, including:

      • userId <String> - The user's ID.

      • email <String> - The user's email.

      • provider <'google'|'apple'|'naver'|'discord'|'email'|'external_token'> - The login provider.

      • use2FA <Boolean> - Whether the user uses two-factor authentication.

    • walletId <String> = The user's wallet ID.

    • userStatus: <UserStatus> - The user's status of wepin login. including:

      • loginStats: <'complete' | 'pinRequired' | 'registerRequired'> - If the user's loginStatus value is not complete, it must be registered in the wepin.

      • pinRequired?:

    • token: <Token> - The user's token of wepin.

      • accessToken: <String>

      • refreshToken <String>

Exception

Example

CompletableFuture<WepinUser> res = wepinLogin.getCurrentWepinUser();
res.whenComplete((wepinUserResponse, error) -> {
  if (error == null) {
      System.out.println("wepinUserResponse: " + wepinUserResponse);
      if (wepinUserResponse.loginStatus == WepinLoginStatus.PIN_REQUIRED || wepinUserResponse.loginStatus == WepinLoginStatus.REGISTER_REQUIRED) {
          // wepin registration
      } else {
          // render logged in UI
      }
  } else {
      // render error UI
      System.out.println("login error: " + error.getMessage());
  }
});

logoutWepin

wepinLogin.logoutWepin()

This method logs out the user logged into Wepin.

Parameters

  • void

Returns

  • CompletableFuture<Boolean>

Exception

Example

CompletableFuture<Boolean> res = wepinLogin.logoutWepin();
res.whenComplete((logoutResponse, error) -> {
  if (error == null) {
      System.out.println("logoutResponse: " + logoutResponse);
  } else {
      // render error UI
      System.out.println("logout error" + error.getMessage())
  }
});

getSignForLogin

Generates signatures to verify the issuer. It is mainly used to generate signatures for login-related information such as ID tokens and access tokens.

wepinLogin.getSignForLogin(privKey, message);

Parameters

  • privKey <String> - The authentication key used for signature generation.

  • message <String> - The message or payload to be signed.

The key for signing can be obtained from Wepin Workspace. In the Development Tools menu, click Get your authentication key on the Login tab to retrieve the authentication key.

Returns

  • String - The generated signature.

The authentication key (privKey) must be stored securely and must not be exposed to the outside. It is recommended to execute the getSignForLogin() method on the backend rather than the frontend for enhanced security and protection of sensitive information.

Example

String privKey = '0400112233445566778899001122334455667788990011223344556677889900'
String idToken = 'idtokenabcdef'
String sign = wepinLogin.getSignForLogin(privKey, idToken)

finalize

wepinLogin.finalize()

This method finalizes the Wepin Login Library.

Parameters

  • void

Returns

  • void

Example

wepinLogin.finalize()

Wepin Error

Last updated