EDIT : http://www.branchtip.com/oauth2callback?error=user_cancelled...
I think here else case is missing.
Another thing IF you mimic actual url param 'http://www.branchtip.com/oauth2callback?code=' it will show ``code length = 0``
^ Might be log.