I'm trying to make login to facebook according to Facebook Server-Side Authentication flow using jsp and servlets. I was succsessfuly login to my fb account but when fb is redirecting to my app, it sends the parameters (state...) after the character '#'. I was looking at this: http://facebook.stackoverflow.com/questions/4144878/get-url-parameters-after-in-java .
but i'm doing it in a different way then they do.
here's my code:
response.sendRedirect(response.encodeRedirectURL("http://www.facebook.com/dialog/oauth/?client_id=343473222406382" +
"&redirect_uri=http://localhost:8080/accountsLogger&response_type=token&state=logged"));
and i'm redirecting to:
{http://localhost:8080/accountsLogger/#state=logged&access_token=AAAE4YxdpUO4BAILjJoj5GsFZBDir1YmZCy4ZC9BmZAOCAztC2QclKo46OSce7dzObL6lSzrYpRDgQycOzzhfbqThR6kVC16lmurC5X5oV1lIrsvI0h9D&expires_in=4329.}
The FB API is built (largely) to be used client-side. The hash-portion of the URL (what is after the '#') is never sent to the server by the browser (which is why you can't pick it up). If you need this information server-side, you need to pick it up using javascript on your accountsLogger page ( document.location.hash
), convert the "hash parameters" into "regular" url-parameters on another URL and redirect the page to that URL.
URL after #
is not sent to the server. It's originally intended as an anchor, it is, something to refer on the downloaded page. The browser then do:
GET /your/url.htm?param1=value¶m2=value
and if there's #someanchor
at the end the browser tries to position the page to make that anchor visible (if it exists).
Old school anchor:
<a name="someanchor">Hello</a>
Standard HTML anchor:
<p id="someanchor">Hello</p>
(thanks @Jon Hanna)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.