Hi I am doing facebook login feature in my application. Now problem is that, when I logged in from facebook account, I am redirected to my specified redirected url with access token. I need to grab this access token in managed bean. My redirected url is like that :
localhost:8080/XXXXXX/myholiday.xhtml#access_token=AAAGHUgDJZCg0BAG2I8o
I have tried:
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
String url = request.getRequestURL().toString();
System.out.println(url);
System.out.println( FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("access_token"));
// Getting request information without the hostname.
String uri = request.getRequestURI();
System.out.println(uri);
Output is the following :
localhost:8080/xxxxxxx/myholiday.xhtml
null
xxxxxxx/myholiday.xhtml
can anyone please help me to grab the access token?
You can not get the access token if it is passed in the hash part of the URL, because the hash part does not get transmitted to the server.
You haven’t shown us, how exactly you call the Auth dialog – but it has a parameter
response_typethat can be set tocodeortoken.codeshould be the default – if you have it set totoken, change that.(Or, if your login gets triggered by Authenticated Referrals, set the
Auth Token Parametersetting in your app settings toQuery String.)Then follow the Server-Side Authentication flow from there.