Contex / XenAPI

This PHP REST API allows usage of several of XenForo functions, such as authentication, user information and many more functions!
http://xenapi.net
GNU Lesser General Public License v3.0
99 stars 41 forks source link

Problem with "login" from external website #42

Open AxelBriche opened 9 years ago

AxelBriche commented 9 years ago

I use:

  $url = $xenAPI->login(
    'Kyna',
    'my_secret_password',
    'http://theming.dev'
  );

  $response = new Symfony\Component\HttpFoundation\RedirectResponse($url);
  $response->send();
  return;

And I have this error: {"error":5,"message":"Authentication error: \"Unable to decrypt login_hash\""}

The url called is: http://xenforo.dev/api.php?action=login&login_hash=5l3l5sy6yCrzXiQ7%2B0x5D5Omf7o74WHHlmsUbRK4Pxg%2BGp4x77Q7VhKw18tZwe2I%2BDlcejI15JcPWuERCqOFEgtpzipC7FyFLIPUZu%2BoBatXfCHfFFl9PKEOgB5joHbHkTRTMDzxzl9mfm%2BeqJxHi3uR5ujIHc9mKeBdeVLSnRs%3D

I use this login function inside xen_api.php:

        public function login($username, $password, $redirect_url)
        {
            $login_hash = $this->encryptString(base64_encode(json_encode(array(
                'username'     => $username,
                'password'     => $password,
                'redirect_url' => $redirect_url
            ))));
            $this->setMethod('login');
            $this->setParameters(array(
                'login_hash' => $login_hash
            ));
            return $this->getAPIURL();
        }