openID login (on localhost) at google app engine -
i've written openid login google app engine.
static { openidproviders = new hashmap<string, string>(); openidproviders.put("google", "https://www.google.com/accounts/o8/id"); openidproviders.put("yahoo", "yahoo.com"); } @override public void doget(httpservletrequest req, httpservletresponse resp) throws ioexception { userservice userservice = userservicefactory.getuserservice(); user user = userservice.getcurrentuser(); // or req.getuserprincipal() set<string> attributes = new hashset(); resp.setcontenttype("text/html"); printwriter out = resp.getwriter(); if (user != null) { out.println("hello <i>" + user.getnickname() + "</i>!"); out.println("[<a href=\"" + userservice.createlogouturl(req.getrequesturi())+ "\">sign out</a>]"); } else { out.println("sign in at: "); (string providername : openidproviders.keyset()) { string providerurl = openidproviders.get(providername); string loginurl = userservice.createloginurl(req.getrequesturi(), null, providerurl, attributes); out.println("[<a href=\"" + loginurl + "\">" + providername+ "</a>] "); } } }
everything works when deploy app. no problems. after choosing openid provider, i'm redirected page:
sample.appspot.com/_ah/login_redir?claimid=[open id provider]=[my sample page]/_ah/login_required
that's servlet.
<servlet> <servlet-name>authorization</servlet-name> <servlet-class>ge.eid.test.authorization</servlet-class> </servlet> <servlet-mapping> <servlet-name>authorization</servlet-name> <url-pattern>/_ah/login_required</url-pattern> </servlet-mapping>
ok. fine! but, when run sampe app @ localhost, have redirection url:
http://localhost:8888/_ah/login?continue=/f_ah/flogin_required
so not have openid login. have that:
question 1) how create openid login @ localhost too.
this normal behaviour, because on localhost might want try many different accounts , mess if had login every time real one. when on localhost can simulate openid user providing email want , checking if want admin or not.
Comments
Post a Comment