1

I would like to parse an url like this one:

http://YOUR_URL/#access_token=166942940015970%7C2.sa0&expires_in=64090

I need to get the value of access_token and expires.

Normally those url should be with question mark like:

http://YOUR_URL/?access_token=166942940015970%7C2.sa0&expires_in=64090

Is there any other possibility than regex with java ?

Could someone tell me why oauth2.0 is with hash sign ("#") and not with question mark ("?") ?

rodrigoap
  • 7,405
  • 35
  • 46
Charles
  • 11,367
  • 10
  • 77
  • 114
  • url.substring(url.indexof("="), url.indexof("%")) for access_token and url.substring(url.lastindexof("="), url.length()) –  Nov 10 '11 at 14:35

1 Answers1

3

The part at the end is an "anchor", and the Java URL class has a method getRef() to return that bit. You'd then have to decode the contents yourself, if necessary.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
  • yeah thanks that was the answer. I did it javascript side with this regex: http://stackoverflow.com/questions/4197591/parsing-url-hash-fragment-identifier-with-javascript/4198132#4198132 – Charles Nov 14 '11 at 13:38