How to recover the access token of a facebook desktop app?

480 Views Asked by At

When I give in the app id the redirect uri that I get will be a:

https://www.facebook.com/connect/login_success.html?code="some long code"

Usually like AQDv7kODxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFUMAQqFdB4l9-Bu_AN34woXMmUzJCx8OwRflcxJ4nHmsWx6Z6jnD9IP2DSqnxIJymXB3GCm2FAeWsADV6fHf471KeC11UTSoQRTn4uqu-SsBjiWECL8Vrf0C8N8#_=_

How do I draw the access token from this code?

1

There are 1 best solutions below

0
On

If you have the url you can do like this. where actoken is your url

 public String getToken() {
        String myu = actoken;

        Pattern startAc = Pattern.compile("="), endAc = Pattern.compile("&");
        Matcher m = startAc.matcher(myu);
        Matcher m1 = endAc.matcher(myu);
        System.out.println(myu);
        while(m.find() && m1.find()) {

            actoken = myu.substring(m.start()+1,m1.end()-1);
        }
        return actoken;
    }