Authenticate your users

Create your auth instance

This instance is used to manage authentication with Viafoura

VFAuthService auth = ViafouraSDK.auth();
val auth = ViafouraSDK.auth()

Get user auth status

Retrieve the current user auth status.

auth.getUserLoginStatus(new AuthService.UserLoginStatusCallback() {
    @Override
    public void onSuccess(boolean userIsLoggedIn) {

    }
});
auth.getUserLoginStatus(object: AuthService.UserLoginStatusCallback {
    override fun onSuccess(userIsLoggedIn: Boolean) {

        }
})

Logout

Log the user out.

auth.logout();
auth.logout()

Basic login

Perform basic login with e-mail and password.

auth.login(email, password, new AuthService.LoginCallback() {
    @Override
    public void onSuccess(LoginResponse loginResponse) {

    }

    @Override
    public void onError(String err) {

    }
});
auth.login(email, password, object: AuthService.LoginCallback {
    override fun onSuccess(loginResponse: LoginResponse) {

    }

    override fun onError(err: String) {

    }
})

Basic signup

auth.signup(name, email, password, new AuthService.SignUpCallback() {
    @Override
    public void onSuccess(SignUpResponse loginResponse) {

    }

    @Override
    public void onError(String err) {

    }
});
auth.signup(name, email, password, new AuthService.SignUpCallback() {
    override fun onSuccess(signupResponse: SignUpResponse) {

    }

    override fun onError(err: String) {

    }
});

Cookie login

More information about how our cookie login works: Cookie Login

auth.cookieLogin(token, new AuthService.CookieLoginCallback() {
    @Override
    public void onSuccess(LoginResponse loginResponse) {

    }

    @Override
    public void onError(String err) {

    }
});
auth.cookieLogin(token, new AuthService.CookieLoginCallback() {
    override fun onSuccess(loginResponse: LoginResponse) {

    }

    override fun onError(err: String) {

    }
});

OpenID login

More information about how our OIDC login works: OIDC Login

auth.openIdLogin(token, new AuthService.OpenIdLoginCallback() {
    @Override
    public void onSuccess(LoginResponse loginResponse) {

    }

    @Override
    public void onError(String err) {

    }
});
auth.openIdLogin(token, new AuthService.OpenIdLoginCallback() {
    override fun onSuccess(loginResponse: LoginResponse) {

    }

    override fun onError(err: String) {

    }
});

Login Radius login

auth.loginRadiusLogin(token, new AuthService.LoginRadiusLoginCallback() {
    @Override
    public void onSuccess(LoginResponse loginResponse) {

    }

    @Override
    public void onError(String err) {

    }
});
auth.loginRadiusLogin(token, new AuthService.LoginRadiusLoginCallback() {
    override fun onSuccess(loginResponse: LoginResponse) {

    }

    override fun onError(err: String) {

    }
});

Social login

auth.socialLogin(token, new AuthService.SocialLoginCallback() {
    @Override
    public void onSuccess(SocialLoginResponse loginResponse) {

    }

    @Override
    public void onError(String err) {

    }
});
auth.socialLogin(token, object: AuthService.SocialLoginCallback {
    override fun onSuccess(loginResponse: SocialLoginResponse) {
        socialLoginCallback.onSuccess()
    }

    override fun onError(err: String) {
        socialLoginCallback.onError()
    }
})

Request password reset

auth.passwordReset(email, new AuthService.PasswordResetCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onError(String err) {

    }
});
auth.passwordReset(email, object: AuthService.PasswordResetCallback {
    override fun onSuccess() {
        callback.onSuccess()
    }

    override fun onError(err: String) {
        callback.onError()
    }
})

What’s Next