Integrating Google AppEngine with a Thick Client

半世苍凉 提交于 2019-12-05 03:00:09

问题


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?


回答1:


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




回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/1689237/integrating-google-appengine-with-a-thick-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!