메서드

Wepin Compose Multiplatform Login Library 에서 제공하는 메서드 입니다.

loginWithOauthProvider

suspend fun loginWithOauthProvider(params: LoginOauth2Params): LoginOauthResult

In-app 브라우저가 열리고 OAuth 제공자에 로그인합니다. Firebase 로그인 정보를 가져오려면 loginWithIdToken() 또는 loginWithAccessToken() 메서드를 호출해야 합니다.

Parameters

  • params <LoginOauth2Params>

    • provider <'google'|'naver'|'discord'|'apple'> 로그인 Provider

    • clientId <String> OAuth 로그인 Provider 의 클라이언트 ID

Returns

  • <LoginOauthResult>

    • provider <String> 사용된 OAuth Provider 의 이름

    • token <String> accessToken(provider 가 'naver' 또는 'discord') 또는 idToken(provider 가 'google' 또는 'apple')

    • type <OauthTokenType> OAuth 토큰의 유형 (id_token , accessToken)

Exception

Example

coroutineScope.launch { 
    wepinLogin.loginWithOauthProvider(LoginOauth2Params(
        provider = "google",
        clientId = "your-google-client-id",
    ))
}

signUpWithEmailAndPassword

suspend fun signUpWithEmailAndPassword(params: LoginWithEmailParams): LoginResult

이메일과 비밀번호를 사용하여 Wepin Firebase 에 가입합니다. 가입이 성공하면 Firebase 로그인 정보를 반환합니다.

Parameters

  • params <LoginWithEmailParams>

    • email <String> 사용자 이메일

    • password <String> 사용자 비밀번호

    • locale <String> 인증 이메일의 언어 설정(기본 값: 'en')

Returns

  • <LoginResult>

    • provider <Providers.EMAIL> 로그인에 사용된 Provider

    • token <FBToken>

      • idToken <String> Wepin Firebase ID 토큰

      • refreshToken <String> Wepin Firebase refresh 토큰

Exception

Example

coroutineScope.launch { 
    wepinLogin.signUpWithEmailAndPassword(
        LoginWithEmailParams(
            email = "abc@defg.com", 
            password = "abcdef123$"
        )
    )
}

loginWithEmailAndPassword

suspend fun loginWithEmailAndPassword(params: LoginWithEmailParams): LoginResult

이메일과 비밀번호를 사용하여 Wepin Firebase 에 로그인합니다. 로그인에 성공하면 Firebase 로그인 정보를 반환합니다.

Parameters

  • params <LoginWithEmailParams>

    • email <String> 사용자 이메일

    • password <String> 사용자 비밀번호

Returns

  • <LoginResult>

    • provider <Providers.EMAIL> 로그인에 사용된 provider

    • token <FBToken>

      • idToken <String> Wepin Firebase ID 토큰

      • refreshToken <String> Wepin Firebase refresh 토큰

Exception

Example

coroutineScope.launch { 
    wepinLogin.loginWithEmailAndPassword(
        LoginWithEmailParams(
            email = "abc@defg.com", 
            password = "abcdef123$"
        )
    )
}

loginWithIdToken

suspend fun loginWithIdToken(params: LoginOauthIdTokenRequest): LoginResult

외부 ID 토큰을 사용하여 WepinFirebase에 로그인합니다. 로그인에 성공하면 Firebase 로그인 정보를 반환합니다.

Parameters

  • params <LoginOauthIdTokenRequest>

    • idToken <String> 로그인에 사용될 ID 토큰 값

    • sign <String> ID 토큰의 서명 값 (getSignForLogin() 의 반환 값)

Returns

  • <LoginResult>

    • provider <Providers.EXTERNAL_TOKEN> - 로그인에 사용된 Provider

    • token <FBToken>

      • idToken <String> Wepin Firebase ID 토큰

      • refreshToken <String> Wepin Firebase refresh 토큰

Exception

Example

coroutineScope.launch { 
    wepinLogin.loginWithIdToken(
        LoginOauthIdTokenRequest(
            idToken = "eyJHGci0...adQssw5c", 
            sign = "9753d4dc...c63466b9"
        )
    )
}

loginWithAccessToken

suspend fun loginWithAccessToken(params: LoginOauthAccessTokenRequest): LoginResult

외부 Access 토큰을 사용하여 Wepin Firebase에 로그인합니다. 로그인에 성공하면 Firebase 로그인 정보를 반환합니다.

Parameters

  • params <LoginOauthAccessTokenRequest>

    • provider <'naver' / 'discord'> Access 토큰을 발급한 Provider

    • accessToken <String> 로그인에 사용될 Access 토큰 값

    • sign <String>

    • Access 토큰의 서명 값 (getSignForLogin() 의 반환 값)

Returns

  • <LoginResult>

    • provider <Provider.EXTERNAL_TOKEN> 로그인에 사용된 Provider

    • token <FBToken>

      • idToken <String> Wepin Firebase ID 토큰

      • refreshToken <String> Wepin Firebase refresh 토큰

Exception

Example

coroutineScope.launch { 
    wepinLogin.loginWithAccessToken(
        LoginOauthAccessTokenRequest(
            provider = "naver",
            accessToken = "eyJHGci0...adQssw5c", 
            sign = "9753d4dc...c63466b9"
        )
    )
}

getRefreshFirebaseToken

suspend fun getRefreshFirebaseToken(): LoginResult

현재 Wepin Firebase 토큰의 정보를 가져옵니다.

Parameters

  • None

Returns

  • <LoginResult>

    • provider <Provider.EXTERNAL_TOKEN> 로그인에 사용된 Provider

    • token <FBToken>

      • idToken <String> Wepin Firebase ID 토큰

      • refreshToken <String> Wepin Firebase refresh 토큰

Exception

Example

coroutineScope.launch { 
    wepinLogin.getRefreshFirebaseToken()
}

loginWepin

suspend fun loginWepin(params: LoginResult?): WepinUser

Wepin Firebase 토큰을 사용하여 Wepin 에 로그인 합니다.

Parameters

Returns

  • <WepinUser>

    • status <'success' | 'fail'> 로그인 상태

    • userInfo <UserInfo> 사용자 정보 (optional)

      • userId <String> 사용자의 ID

      • email <String> 사용자의 이메일

      • provider <'google' | 'apple' | 'naver' | 'discord' | 'email' | 'external_token'> 로그인 Provider

      • use2FA <Boolean> 사용자가 이중 인증을 사용하는지 여부

    • walletId <String> 사용자의 지갑 ID

    • userStatus <UserStatus> 사용자의 Wepin 로그인 상태 (optional)

      • loginStatus <WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'> 사용자의 loginStatus 가 'complete' 상태가 아닌 경우, 사용자는 Wepin 에 register 해야 합니다.

      • pinRequired <Boolean> PIN 이 필요한지 여부

    • token <Token> 사용자의 Wepin 토큰

      • accessToken <String> Access Token

      • refreshToken <String> Refresh Token

Exception

Example

coroutineScope.launch { 
    val wepinLogin: WepinLogin = WepinLogin(
        WepinLoginOptions(
            context = context,
            appId = appId,
            appKey = appKey
        )
    )
    wepinLogin.init()
    
    val response = wepinLogin.loginWithOauthProvider(
        LoginOauth2Params(
            provider = "google",
            clientId = "your-google-client-id"
        )
    )
    val sign = wepinLogin.getSignForLogin(
        privateKeyHex = "private key", 
        message = response.token
    )
    var loginResult: LoginResult? = null
    if (response.provider == "naver" || response.provider = "discord") {
        loginResult = wepinLogin.loginWithAccessToken(
            LoginOauthAccessTokenRequest(
                provider = response.provider,
                token = response.token,
                sign = sign
            )
        )
    } else {
        loginResult = wepinLogin.loginWithIdToken(
            LoginOauthIdTokenRequest(
                idToken = response.token,
                sign = sign
            )
        )
    }
    val userInfo = wepinLogin.loginWepin(loginResult)
    val userStatus = userInfo.userStatus
    if (userStatus.loginStatus != WepinLoginStatus.COMPLETE) {
        //Wepin Register 코드..
    }
}

getCurrentWepinUser

suspend fun getCurrentWepinUser(): WepinUser

Wepin 에 현재 로그인한 사용자의 정보를 가져옵니다.

Parameters

  • None

Returns

  • <WepinUser>

    • status <'success' | 'fail'> 로그인 상태

    • userInfo <UserInfo> 사용자 정보 (optional)

      • userId <String> 사용자의 ID

      • email <String> 사용자의 이메일

      • provider <'google' | 'apple' | 'naver' | 'discord' | 'email' | 'external_token'> 로그인 Provider

      • use2FA <Boolean> 사용자가 이중 인증을 사용하는지 여부

    • walletId <String> 사용자의 지갑 ID

    • userStatus <UserStatus> 사용자의 Wepin 로그인 상태 (optional)

      • loginStatus <WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'> 사용자의 loginStatus 가 'complete' 상태가 아닌 경우, 사용자는 Wepin 에 register 해야 합니다.

      • pinRequired <Boolean> PIN 이 필요한지 여부

    • token <Token> 사용자의 Wepin 토큰

      • accessToken <String> Access Token

      • refreshToken <String> Refresh Token

Exception

Example

coroutineScope.launch {
    val userInfo = wepinLogin.getCurrentWepinUser()
    val userStatus = userInfo.userStatus!!
    if (userStatus.loginStatus != WepinLoginStatus.COMPLETE) {
        //Wepin Register 코드..
    }
}

logoutWepin

suspend fun logoutWepin(): Boolean

Wepin에 로그인한 사용자를 로그아웃 합니다.

Parameters

  • None

Returns

  • <Boolean>

Exception

Example

coroutineScope.launch {
    wepinLogin.logoutWepin()
}

getSignForLogin

fun getSignForLogin(privateKeyHex: String, message: String): String

발급자를 확인하기 위한 서명을 생성합니다. 주로 ID 토큰 및 Access 토큰과 같은 로그인 관련 정보를 위한 서명을 생성하는데 사용합니다.

Parameters

  • privateKey <String> 명 생성에 사용되는 인증 키

  • message <String> 서명될 메시지 또는 페이로드

서명에 사용할 키는 위핀 워크스페이스에서 발급 받을 수 있습니다. 개발 도구 메뉴에서 로그인 탭의 인증키 발급 받기를 클릭하여 인증키를 확인하세요.

Returns

  • <String> - 생성된 서명

인증 키(privateKey)는 반드시 안전하게 보관되어야 하며, 외부에 노출되지 않도록 주의해야 합니다. 보안과 민감한 정보 보호를 위해 getSignForLogin() 메서드는 프론트엔드가 아닌 백엔드에서 실행하는 것이 권장됩니다. 서명 생성 방법에 대해서는 아래 문서를 참고하세요.

Exception

Example

wepinLogin.getSignForLogin(
    privateKeyHex = "private key", 
    message = "idtokenoraccesstoken"
) 

finalize

fun finalize()

WepinLoginLibrary 를 종료합니다.

Parameters

  • None

Returns

  • None

Exception

Example

wepinLogin.finalize()

Wepin Error

Error CodeError MessageError Description

INVALID_APP_KEY

"Invalid app key"

The Wepin app key is invalid.

INVALID_PARAMETER `

"Invalid parameter"

One or more parameters provided are invalid or missing.

INVALID_LOGIN_PROVIDER

"Invalid login provider"

The login provider specified is not supported or is invalid.

INVALID_TOKEN

"Token does not exist"

The token does not exist.

INVALID_LOGIN_SESSION

"Invalid Login Session"

The login session information does not exist.

NOT_INITIALIZED_ERROR

"Not initialized error"

The WepinLoginLibrary has not been properly initialized.

ALREADY_INITIALIZED_ERROR

"Already initialized"

The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again.

NOT_ACTIVITY

"Context is not activity"

The Context is not an activity

USER_CANCELLED

"User cancelled"

The user has cancelled the operation.

UNKNOWN_ERROR

"An unknown error occurred"

An unknown error has occurred, and the cause is not identified.

NOT_CONNECTED_INTERNET

"No internet connection"

The system is unable to detect an active internet connection.

FAILED_LOGIN

"Failed to Oauth log in"

The login attempt has failed due to incorrect credentials or other issues.

ALREADY_LOGOUT

"Already Logout"

The user is already logged out, so the logout operation cannot be performed again.

INVALID_EMAIL_DOMAIN

"Invalid email domain"

The provided email address's domain is not allowed or recognized by the system.

FAILED_SEND_EMAIL

"Failed to send email"

The system encountered an error while sending an email. This is because the email address is invalid or we sent verification emails too often. Please change your email or try again after 1 minute.

REQUIRED_EMAIL_VERIFIED

"Email verification required"

Email verification is required to proceed with the requested operation.

INCORRECT_EMAIL_FORM

"Incorrect email format"

The provided email address does not match the expected format.

INCORRECT_PASSWORD_FORM

"Incorrect password format"

The provided password does not meet the required format or criteria.

NOT_INITIALIZED_NETWORK

"Network Manager not initialized"

The network or connection required for the operation has not been properly initialized.

REQUIRED_SIGNUP_EMAIL

"Email sign-up required."

The user needs to sign up with an email address to proceed.

FAILED_EMAIL_VERIFIED

"Failed to verify email."

The WepinLoginLibrary encountered an issue while attempting to verify the provided email address.

FAILED_PASSWORD_SETTING

"Failed to set password."

The WepinLoginLibrary failed to set the password.

EXISTED_EMAIL

"Email already exists."

The provided email address is already registered in Wepin.

Last updated