public static final String BadAuthentication = "BadAuthentication";
public static final String NotVerified = "NotVerified";
public static final String TermsNotAgreed = "TermsNotAgreed";
public static final String CaptchaRequired = "CaptchaRequired";
public static final String Unknown = "Unknown";
public static final String AccountDeleted = "AccountDeleted";
public static final String AccountDisabled = "AccountDisabled";
public static final String ServiceDisabled = "ServiceDisabled";
public static final String ServiceUnavailable = "ServiceUnavailable";
private static final Map<String, String> errorMsg = new HashMap<String, String>();
static {
errorMsg.put(BadAuthentication,
"The login request used a username or password that is not recognized.");
errorMsg.put(
NotVerified,
"The account email address has not been verified. The user will need to access their Google account directly to resolve the issue before logging in using a non-Google application.");
errorMsg.put(
TermsNotAgreed,
"The user has not agreed to terms. The user will need to access their Google account directly to resolve the issue before logging in using a non-Google application.");
errorMsg.put(
CaptchaRequired,
"A CAPTCHA is required. (A response with this error code will also contain an image URL and a CAPTCHA token.)");
errorMsg.put(
Unknown,
"The error is unknown or unspecified; the request contained invalid input or was malformed.");
errorMsg.put(AccountDeleted, "The user account has been deleted.");
errorMsg.put(AccountDisabled, "The user account has been disabled.");
errorMsg.put(
ServiceDisabled,
"The user's access to the specified service has been disabled. (The user account may still be valid.)");
errorMsg.put(ServiceUnavailable,
"The service is not available; try again later.");
}
private String errorMessage;
private String captchaToken;
private String captchaUrl;
private HttpTransport transport;
private ClientLogin authenticator;
private String authToken;
private String service;
/**
* @param service
*/
public GoogleClientLogin(String service) {
super();
this.service = service;
authenticator = new ClientLogin();
transport = GoogleTransport.create();
authenticator.authTokenType = service;
}
/**
* @param username
* @param password
* @throws ClientLoginException
*/
public void authenticate(String username, String password)