Java Code Examples for io.particle.android.sdk.cloud.models.SignUpInfo#setGrantType()

The following examples show how to use io.particle.android.sdk.cloud.models.SignUpInfo#setGrantType() . 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 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 orgSlug    Organization slug to use
 * @deprecated Use product id or product slug instead
 */
@WorkerThread
@Deprecated
public void signUpAndLogInWithCustomer(SignUpInfo signUpInfo, String orgSlug)
        throws ParticleCloudException {
    if (!all(signUpInfo.getUsername(), signUpInfo.getPassword(), orgSlug)) {
        throw new IllegalArgumentException(
                "Email, password, and organization must all be specified");
    }

    signUpInfo.setGrantType("client_credentials");
    try {
        Responses.LogInResponse response = identityApi.signUpAndLogInWithCustomer(signUpInfo, orgSlug);
        onLogIn(response, signUpInfo.getUsername(), signUpInfo.getPassword());
    } catch (RetrofitError error) {
        throw new ParticleCloudException(error);
    }
}