I implemented a Facebook app with Java servlets. I wonder how I can read the access token from the HTTP request sent by Facebook after authentication.
The request sent to me by Facebook looks like this: http://myserver/app/servlet#access_token=3108888%7C2.AQByEGAdEk7D5hs3.3600.130400.1-10005014%7C3XTVE&expires_in=4317
How can I read the access token (which is a fragment and not a parameter) in my Java servlet? If it was a parameter I wou开发者_JAVA技巧ld do:
request.getParameter("access_token);
To make facebook send the request which contains access_token in http parameters, one needs to change the resoponse_type
parameter in request. It is of two types code
and token
. If we pass token
the access_code
will be in url fragment and if we pass token
it will be request parameter with key as code
.
See: Constructing a URL to the OAuth Dialog
For server side handling of access_code
e.g. in some servlet, it is needed to send request_type
as code
else it can be handled only in client side through javascript.
精彩评论