"Captcha Required" when authenticating with a google apps account

305 views
Skip to first unread message

Abhinav Bhagwat

unread,
Mar 6, 2010, 8:10:03 AM3/6/10
to Google App Engine
Hi,

I am trying to authenticate using to Google Spreadsheet service using
a google apps account. I always get a error "Captcha Required". My
code is as below:-

SpreadsheetService service = new SpreadsheetService("__SMS_CRON");
try {
service.setUserCredentials(Configuration.get().getEmailUsername(),
Configuration.get().getEmailPassword());
SpreadsheetFeed feed = service.getFeed(new URL("http://
spreadsheets.google.com/feeds/spreadsheets/private/full"),
SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();

} catch (AuthenticationException e) {
log.severe("Authentication Failed!");
e.printStackTrace();
}


I get the following exception when I use a google apps username and
password. Whereas if I use a google username and password it works
correctly without any error.

com.google.gdata.client.GoogleService$CaptchaRequiredException:
Captcha required
at
com.google.gdata.client.GoogleAuthTokenFactory.getAuthException(GoogleAuthTokenFactory.java:
619)
at
com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:
500)
at
com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:
346)
at
com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:
362)
at
com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:
317)
at
com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:
301)
at in.abhicode.sms.ProcessMainSheet.doGet(ProcessMainSheet.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)

Kindly help.

Thanks,
Abhi

Ikai L (Google)

unread,
Mar 11, 2010, 3:14:35 PM3/11/10
to google-a...@googlegroups.com
Have you seen this FAQ page?

http://code.google.com/googleapps/faq.html

"How do we handle a CAPTCHA challenge?

There are 2 ways to handle a CAPTCHA challenge:

Your application can display the CAPTCHA image and solicit an answer
from the user. To display the CAPTCHA image, use the CaptchaUrl
returned with the login failure response. Once the user provides an
answer, your application should resend (POST) the login request, this
time including the CAPTCHA token and the user's answers. Google will
validate the user's answer before authorizing access to the account.
So, when responding to a CAPTCHA, your POST body string will look like
the following:
accountType=HOSTED&Email=joh...@yourdomain.com&Passwd=north23AZ&logintoken=DQAAAGgA...dkl1LK9&logincaptcha=randomized

Your application can direct the user to the Google hosted page:
https://www.google.com/a/yourdomain.com/UnlockCaptcha
Note: Please replace yourdomain.com with your domain name.

Once the user has successfully responded to the challenge, the Google
server will trust the computer in use. The application can then resend
the original login request to obtain the authentication token."

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

--
Ikai Lan
Developer Programs Engineer, Google App Engine
http://googleappengine.blogspot.com | http://twitter.com/app_engine

Reply all
Reply to author
Forward
0 new messages