Getting users email

41 views
Skip to first unread message

Jonathan Kelada

unread,
Feb 11, 2012, 1:06:40 AM2/11/12
to gwt-oaut...@googlegroups.com
Hi,

I'm a student and new to GWT and OAuth, so pardon my ignorance. I'm having some trouble using the token given to me once the user has granted me access (I'm using the java version).

What I'm trying to do is get the users email address which I should be able to do using the following URL:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<token_here>

If I paste that same URL into my browser (with the token I was granted) I'm given a JSON response (see bellow), which would be perfect because that's all I want and I can parse that very easily.

{
 "issued_to": "**************.apps.googleusercontent.com",
 "audience": "**************.apps.googleusercontent.com",
 "scope": "https://www.googleapis.com/auth/userinfo.email",
 "expires_in": 2557,
 "email": "*************@gmail.com",
 "verified_email": true,
 "access_type": "online"
}

I figured I could just use the standard GWT HTTP GET request:
http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/DevGuideHttpRequests

However, when I send my GET request, I don't get a response back at all. Why is this? How can I get the users email address?

Any help would be greatly appreciated,
Jonathan

Jason Hall

unread,
Feb 12, 2012, 11:15:54 AM2/12/12
to gwt-oaut...@googlegroups.com
Making a regular GET call will not work if you are using RequestBuilder because of the Same Origin Policy in your browser (http://en.wikipedia.org/wiki/Same_origin_policy)


Let me know if you have any problems after using JSONP.

- Jason

Jonathan Kelada

unread,
Feb 12, 2012, 4:50:42 PM2/12/12
to gwt-oaut...@googlegroups.com
That worked perfectly, thank you.

Jonathan
Reply all
Reply to author
Forward
0 new messages