English 中文(简体)
Integrating Google AppEngine with a Thick Client
原标题:

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end.

The problem is that GAE provides only web-based forms for logging in and out, so there s no trivial way to employ Google Accounts features in a thick client.

Can you give some advices/hints/ideas on how to allow a thick client login to and logout from a GAE webapp?

最佳回答

There is a way for client apps to authenticate against Google Accounts, but I don t know if the token you receive can be passed back to AppEngine. See: ClientLogin for Installed Applications

问题回答

I am sorry, I can only answer you indirectly. It is possible to log in to an app on appspot.com with a Google account. You just have to do everything a browser would, including keeping some cookies and contacting several servers as they bounce you around.

I played around with this for a stillborn project a couple of months ago and ended up with a shell script that mostly runs cURL to log in. Perhaps you could take from it what you need.

#!/bin/bash

my_app="set-this-to-my-app-id"
url="http://$my_app.appspot.com"
curl= curl --cookie-jar cookies 

if [ -z "$EMAIL" -o -z "$PASS" ]; then
    echo -n  Email:  
    read EMAIL
    echo -n  Pass:  
    read PASS
fi

rm -f cookies auth

echo  Login 
$curl https://www.google.com/accounts/ClientLogin --output auth 
      -d "Email=$EMAIL" -d "Passwd=$PASS" 
      -d accountType=HOSTED_OR_GOOGLE     
      -d source=$my_app                   
      -d service=ah

. auth # XXX Be careful here. The output of the above
       # command happens to be Bash syntax too!
rm -f auth

echo  Logging into app and getting cookie 
$curl "$url/_ah/login?continue=$url/console/&auth=$Auth"

echo
echo  Example POST query 
$curl -X POST --cookie cookies "$url/some/path" -d  foo=bar 

echo
rm -f cookies

as suggested by @Jason DeFontes the ClientLogin authorization process is addressing this issue.

as a minimal-effort alternative approach, you could embed the web-based (html) forms into your thick client, i.e. use a java component that supports html-rendering (like a JEditorPane with an HTMLEditorKit installed) and present this component inside your swing app -- at least users would not need to switch back-and-forth between your app and the browser this way.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签