Wepin Android Login Library에서 제공하는 메서드 입니다.
loginWithOauthProvider
Copy wepinLogin . loginWithOauthProvider (params)
In-app browser가 열리고 OAuth provider에 로그인 합니다. Firebase 로그인 정보를 가져오려면 loginWithIdToken() 또는 loginWithAccessToken() 메서드를 호출해야 합니다.
Parameters
params
<LoginOauth2Params>
provider
<'google'|'naver'|'discord'|'apple'> - Provider for login
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
Java Kotlin
Copy 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 ())
}
});
Copy val loginOption = LoginOauth2Params (
provider = "discord" ,
clientId = getString (R.string.default_discord_client_id),
)
wepinLogin. loginWithOauthProvider (loginOption). whenComplete { loginResponse, error ->
if (error == null ) {
// render logged in UI
println (loginResponse)
val privateKey = "private key for wepin id/access Token"
// token sign
wepinLogin. getSignForLogin (loginResponse.token, privateKey)
//call loginWithIdToken() or loginWithAccessToken()
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
signUpWithEmailAndPassword
Copy wepinLogin . signUpWithEmailAndPassword (params)
이메일과 비밀번호를 사용하여 Wepin Firebase에 가입합니다. 가입이 성공하면 Firebase 로그인 정보를 반환합니다.
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
Java Kotlin
Copy 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 ())
}
});
Copy val loginOption = LoginWithEmailParams (
email = "abc@defg.com" ,
password = "abcdef123&" ,
language = "ko"
)
wepinLogin. signUpWithEmailAndPassword (loginOption). whenComplete { loginResponse, error ->
if (error == null ) {
// render logged in UI
println (loginResponse)
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
loginWithEmailAndPassword
Copy wepinLogin . loginWithEmailAndPassword (params)
이메일과 비밀번호를 사용하여 Wepin Firebase에 로그인합니다. 로그인에 성공하면 Firebase 로그인 정보를 반환합니다.
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
Java Kotlin
Copy 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 ())
}
});
Copy val loginOption = LoginWithEmailParams (
email = "abc@defg.com" ,
password = "abcdef123&" ,
language = "ko"
)
wepinLogin. loginWithEmailAndPassword (loginOption). whenComplete { loginResponse, error ->
if (error == null ) {
// render logged in UI
println (loginResponse)
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
loginWithIdToken
Copy wepinLogin . loginWithIdToken (params)
외부 ID 토큰을 사용하여 Wepin Firebase에 로그인합니다. 로그인에 성공하면 Firebase 로그인 정보를 반환합니다.
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
Java Kotlin
Copy 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 ())
}
});
Copy val token = "eyJHGciO....adQssw5c"
val sign = "9753d4dc...c63466b9"
val loginOption = new LoginOauthIdTokenRequest (token, sign)
wepinLogin. loginWithIdToken (loginOption). whenComplete { loginResponse, error ->
if (error == null ) {
// render logged in UI
println (loginResponse)
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
loginWithAccessToken
Copy wepinLogin . loginWithAccessToken (params)
외부 Access 토큰을 사용하여 Wepin Firebase에 로그인합니다. 로그인에 성공하면 Firebase 로그인 정보를 반환합니다.
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
Java Kotlin
Copy 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 ())
}
});
Copy val accessToken = "eyJHGciO....adQssw5c"
val sign = "9753d4dc...c63466b9"
val loginOption = LoginOauthAccessTokenRequest (
provider = "discord" ,
accessToken = accessToken, sign = sign
)
wepinLogin. loginWithAccessToken (loginOption). whenComplete { loginResponse, error ->
if (error == null ) {
// render logged in UI
println (loginResponse)
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
getRefreshFirebaseToken
Copy wepinLogin . getRefreshFirebaseToken ()
현재 Wepin Firebase 토큰의 정보를 가져옵니다.
Parameters
Returns
CompletableFuture<LoginResult>
token
<FBToken>
idToken
<String> - wepin firebase idToken
refreshToken
` - wepin firebase refreshToken
Exception
Example
Java Kotlin
Copy 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 ());
}
});
Copy wepinLogin. getRefreshFirebaseToken (). whenComplete { firebaseResponse, error ->
if (error == null ) {
println (firebaseResponse)
// render logged in UI
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
loginWepin
Copy wepinLogin . loginWepin (param)
지정된 공급자와 토큰을 사용하여 사용자를 Wepin에 로그인합니다.
Parameters
매개변수는 이 모듈 내에서 loginWithEmailAndPassword(), loginWithIdToken(), loginWithAccessToken() 메서드의 반환 값을 활용해야 합니다.
<LoginResult>
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.
token: <Token> - The user's token of wepin.
Exception
Example
Java Kotlin
Copy 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 ())
}
});
Copy val accessToken = "eyJHGciO....adQssw5c"
val sign = "9753d4dc...c63466b9"
val loginOption = LoginOauthAccessTokenRequest (
provider = "discord" ,
accessToken = accessToken, sign = sign
)
wepinLogin. loginWithAccessToken (loginOption). whenComplete { loginResponse, error ->
if (error == null ) {
println (loginResponse)
wepinLogin. loginWepin (loginResponse). whenComplete { loginWepinResponse, err ->
if (err == null ) {
println (loginWepinResponse)
if(loginWepinResponse.loginStatus === WepinLoginStatus.PIN_REQUIRED||loginWepinResponse.loginStatus === WepinLoginStatus.REGISTER_REQUIRED) {
// wepin registration
} else {
// render logged in UI
}
} else {
println ( "login err - ${ err.message } " )
// render error UI
}
}
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
getCurrentWepinUser
Copy wepinLogin . getCurrentWepinUser ()
이 메서드는 Wepin에 현재 로그인한 사용자의 정보를 가져옵니다.
Parameters
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.
token: <Token> - The user's token of wepin.
Exception
Example
Java Kotlin
Copy 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 ());
}
});
Copy wepinLogin. getCurrentWepinUser (). whenComplete { wepinUserResponse, error ->
if (error == null ) {
println (wepinUserResponse)
if (wepinUserResponse.loginStatus == WepinLoginStatus.PIN_REQUIRED || wepinUserResponse.loginStatus == WepinLoginStatus.REGISTER_REQUIRED) {
// wepin registration
} else {
// render logged in UI
}
} else {
println ( "login error - ${ error.message } " )
// render error UI
}
}
logoutWepin
Copy wepinLogin . logoutWepin ()
Wepin에 로그인한 사용자를 로그아웃합니다.
Parameters
Returns
CompletableFuture<Boolean>
Exception
Example
Java Kotlin
Copy 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 ())
}
});
Copy wepinLogin. logoutWepin (). whenComplete { logoutResponse, error ->
if (error == null ) {
println (logoutResponse)
} else {
println ( "logout error - ${ error.message } " )
// render error UI
}
}
getSignForLogin
발급자를 확인하기 위한 서명을 생성합니다. 주로 ID 토큰 및 Access 토큰과 같은 로그인 관련 정보를 위한 서명을 생성하는 데 사용됩니다.
Copy wepinLogin. getSignForLogin (privKey, message);
Parameters
privKey
<String> - The authentication key used for signature generation.
message
<String> - The message or payload to be signed.
Returns
String - The generated signature.
인증 키(privKey)는 안전하게 저장되어야 하며 외부에 노출되어서는 안 됩니다. 보안과 민감한 정보 보호를 강화하기 위해 getSignForLogin() 메서드는 프론트엔드가 아닌 백엔드에서 실행하는 것이 권장됩니다.
Example
Java Kotlin
Copy String privKey = '0400112233445566778899001122334455667788990011223344556677889900'
String idToken = 'idtokenabcdef'
String sign = wepinLogin . getSignForLogin (privKey , idToken)
Copy val privKey = '0400112233445566778899001122334455667788990011223344556677889900'
val idToken = 'idtokenabcdef'
val sign = wepinLogin. getSignForLogin (privKey, idToken)
finalize
Copy wepinLogin . finalize ()
Wepin Login Library 를 종료 합니다.
Parameters
Returns
Example
Java Kotlin
Copy wepinLogin . finalize ()
Copy wepinLogin. finalize ()
Wepin Error
Error Code Error Message Error Description The Wepin app key is invalid.
One or more parameters provided are invalid or missing.
The login provider specified is not supported or is invalid.
The token does not exist.
The login session information does not exist.
The WepinLoginLibrary has not been properly initialized.
ALREADY_INITIALIZED_ERROR
The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again.
"Context is not activity"
The Context is not an activity
The user has cancelled the operation.
"An unknown error occurred"
An unknown error has occurred, and the cause is not identified.
The system is unable to detect an active internet connection.
The login attempt has failed due to incorrect credentials or other issues.
The user is already logged out, so the logout operation cannot be performed again.
The provided email address's domain is not allowed or recognized by the system.
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.
"Email verification required"
Email verification is required to proceed with the requested operation.
The provided email address does not match the expected format.
"Incorrect password format"
The provided password does not meet the required format or criteria.
"Network Manager not initialized"
The network or connection required for the operation has not been properly initialized.
"Email sign-up required."
The user needs to sign up with an email address to proceed.
"Failed to verify email."
The WepinLoginLibrary encountered an issue while attempting to verify the provided email address.
"Failed to set password."
The WepinLoginLibrary failed to set the password.
The provided email address is already registered in Wepin.