views:

167

answers:

2

How do I use OAuth within my Java GWT application? In particular, I want to get a list of users in my Google Aps domain, using this API:

http://code.google.com/googleapps/domain/profiles/developers_guide_protocol.html

I know this sounds like a question, that probably has been asked many times before, but I couldn't find any Java code on how to realize the OAuth steps described in the API above.

I would be glad if someone could share some code, or point me to the right docs.

+4  A: 

This tutorial by Matt Raible is easily the best one I've seen so far on OAuth and gwt. He also has a very good picture depicting the authentication flow, which I always find help. However, as Matt himself says, the solution is not 100% reliable, but it might still get you part of the way.

With this in mind, it might be better to just go with a pure javascript implementation of it. You'll find one such implementation right here. This SO thread might come in handy to you if you chose that path.

Best of luck to you.

Banang
+2  A: 

What do you mean in your GWT application? Do you mean client-side only?

Because on the server you can easily use the Scribe OAuth library (http://github.com/fernandezpablo85/scribe-java).

It has a good documentation and is fairly simple to use.

Simeon
I will need server side authentication, for I don't want the user to be able to modify the list of users for his domain. But I'm not sure, if Scribe is what I'm searching for. To use it you seam to need an API_KEY and API_SECRET. However Google does not provide such for the Apps profiles API. As far as I understand this is because scribe is for 2-legged-auth and what I'm trying to achive is 3-legged-auth, meaning, I like the user to authenticate with Google, not my server with Google, right?
JochenJung
Yes unfortunately you are right (I think), Scribe helps for 2 legged auth only. I will however have a more thorough look at it (although you have probably done that already) and I'll edit my answer if I find anything.
Simeon
Found the API_KEY and _SECRET in Google Apps settings. Though I'm still not sure whether its gonna work, I think Scribe is the best library available. Thx.
JochenJung