io.particle.android.sdk.cloud.exceptions.ParticleLoginException Java Examples

The following examples show how to use io.particle.android.sdk.cloud.exceptions.ParticleLoginException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParticleCloud.java    From spark-sdk-android with Apache License 2.0 6 votes vote down vote up
/**
 * Create new customer account on the Particle cloud and log in
 *
 * @param signUpInfo Required sign up information, must contain a valid email address and password
 * @param productId  Product id to use
 */
@WorkerThread
public void signUpAndLogInWithCustomer(SignUpInfo signUpInfo, Integer productId)
        throws ParticleCloudException {
    if (!all(signUpInfo.getUsername(), signUpInfo.getPassword(), productId)) {
        throw new IllegalArgumentException(
                "Email, password, and product id must all be specified");
    }

    signUpInfo.setGrantType("client_credentials");
    try {
        Responses.LogInResponse response = identityApi.signUpAndLogInWithCustomer(signUpInfo, productId);
        onLogIn(response, signUpInfo.getUsername(), signUpInfo.getPassword());
    } catch (RetrofitError error) {
        throw new ParticleLoginException(error);
    }
}
 
Example #2
Source File: ParticleCloud.java    From spark-sdk-android with Apache License 2.0 5 votes vote down vote up
/**
 * Login with existing account credentials to Particle cloud
 *
 * @param user     User name, must be a valid email address
 * @param password Password
 */
@WorkerThread
public void logIn(String user, String password) throws ParticleCloudException {
    try {
        Responses.LogInResponse response = identityApi.logIn("password", user, password);
        onLogIn(response, user, password);
    } catch (RetrofitError error) {
        throw new ParticleLoginException(error);
    }
}
 
Example #3
Source File: ParticleCloud.java    From spark-sdk-android with Apache License 2.0 5 votes vote down vote up
/**
 * Login with existing account credentials to Particle cloud
 *
 * @param user     User name, must be a valid email address
 * @param password Password
 * @param mfaToken Multi factor authentication token from server.
 * @param otp      One time password from authentication app.
 */
@WorkerThread
public void logIn(String user, String password, String mfaToken, String otp) throws ParticleCloudException {
    try {
        Responses.LogInResponse response = identityApi.authenticate("urn:custom:mfa-otp", mfaToken, otp);
        onLogIn(response, user, password);
    } catch (RetrofitError error) {
        throw new ParticleLoginException(error);
    }
}
 
Example #4
Source File: ParticleCloud.java    From spark-sdk-android with Apache License 2.0 5 votes vote down vote up
/**
 * Create new customer account on the Particle cloud and log in
 *
 * @param email     Required user name, must be a valid email address
 * @param password  Required password
 * @param productId Product id to use
 */
@WorkerThread
public void signUpAndLogInWithCustomer(String email, String password, Integer productId)
        throws ParticleCloudException {
    try {
        signUpAndLogInWithCustomer(new SignUpInfo(email, password), productId);
    } catch (RetrofitError error) {
        throw new ParticleLoginException(error);
    }
}