开发者

Using Oauth to connect a Java application with a GAE application

开发者 https://www.devze.com 2023-03-13 20:07 出处:网络
I have a Java application and a GAE application, that sends C2DM messages to Android devices. Now I would like to make the users of the java application able to sign in via their Google accounts to

I have a Java application and a GAE application, that sends C2DM messages to Android devices.

Now I would like to make the users of the java application able to sign in via their Google accounts to the GAE application. Am I correct, that I need to use oauth to realize this?

A litte bit of background:

+-----------+                        +----------+
| JAVA App  |  send Message to --->  | GAE App  | 
+-----------+                        +----------+
  ^                                         |
  | Notify Client                           |
  ---------------------------- <User is allowed to send>
                                            |
                                            |
                                   开发者_开发技巧       [YES] ---> Start delivering C2DMessage

I hope my great ASCII picture make it easier to understand ;)

Somehow I need to allow the user to login in the java application with their google credentials and if I send a message to the server the user data is being sent with the message to the server.

I do not really have an idea how to do this. It would be great, if you could tell me, wheter I am on the right or wrong track. I would be really glad for any suggestions.

Thanks, Mark


OAuth is used when your application need to access resources or perform operation on another service on the behalf of the user (without needing their credentials).

Depending on what is your Java application (desktop, web, mobile), you will use different OAuth flow as shown in the Auth documentation for Google APIs.

And no need for the user to login in the Java application, as long as they are logged in the GAE application, you should be able to retrieve an Access Token from GAE OAuth end points.

Note that GAE only support OAuth 1.0, when acting as an OAuth provider, see the GAE OAuth Documentation for more details.

Also Ikai recently made a blog post detailing how to setup a OAuth provider on GAE/Java.

As a side note, did you take a look at the latest GPE version, it features tooling for developing Android Application with a GAE backend, as show in this year Google I/O presentation

Hope that helps.


If you're going to use GAE, instead of using OAuth, why not use the Users API?

http://code.google.com/appengine/docs/java/users/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号