How do I use OAuth within my GWT application?

2019-01-18 04:39发布

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.

3条回答
Emotional °昔
2楼-- · 2019-01-18 04:46

For integrating OAuth and GWT, you should start with Scribe which handles the implementation of the OAuth:

https://github.com/fernandezpablo85/scribe-java

Next, you need to create a GWT widget that can handle the user's interactions to acquire permission to access their account. Then grab the response token, and make the API requests to the external site.

No point re-implementing OAuth when scribe already does it for you - you just need to. I'd probably aim to use a GWT Popup for doing the authentication:

http://gwt.google.com/samples/Showcase/Showcase.html#!CwBasicPopup

查看更多
我只想做你的唯一
3楼-- · 2019-01-18 04:52

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.

查看更多
劳资没心,怎么记你
4楼-- · 2019-01-18 05:03

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.

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

查看更多
登录 后发表回答