Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random failed authentication #26

Open
avramovic opened this issue Mar 17, 2016 · 6 comments
Open

Random failed authentication #26

avramovic opened this issue Mar 17, 2016 · 6 comments

Comments

@avramovic
Copy link

Randomly the API fails to authenticate. It returns false and I have no idea what's causing this, but the code fails to add user to the list. Refresh of the page immediately "solves" the problem because then it works, but it's happening quite often and it's not acceptable for my client.

This is my code (from my own class constructor)

$this->api = new phpListRESTApiClient('http://www.xxxxx.com/mailer/admin/?page=call&pi=restapi', 'admin', 'xxxxxx', 'b2xxxxxxx9');
$connected = $this->api->login();
if (!$connected) {
  throw new RestApiException("Something is wrong with the phpList login!");
}

Is there any way to get more info about this issue? Is it known issue? Any ideas how to solve it?

@michield
Copy link
Member

Problems like that are hard to debug. It could be connectivity issues, like DB or network. Best thing to do is to hack the code and add some logging in places and see how far it gets.

@djaho
Copy link

djaho commented Dec 8, 2018

Hi,
I know this is a very old issue for a project which is essentially dead. But I had a similar issue with a newer version of a plugin and maybe my answer will help somebody somewhere.
My issue was that the login to phplist failed for new sessions, but it succeeded for all subsequent sessions. This happened because the curl request sent a session cookie which already expired (from previous session) and phplist refused the login.
So the fix was quite simple.
You just have to add CURLOPT_COOKIESESSION to the curl request whenever you try to create a new session. It is best to extend the callApi function to accept a new parameter $newSession (true/false) and then use it like this
curl_setopt($c, CURLOPT_COOKIESESSION, $newSession);

When you call it from login function, pass the $newSession parameter as true and when called from other functions, set it to default to false.

A link to the curl documentation:
http://php.net/manual/en/function.curl-setopt.php

@samtuke
Copy link
Contributor

samtuke commented Dec 8, 2018

Thanks for sharing. Do you plan to migrate to the new REST API (https://github.com/phpList/rest-API) at some stage?

@djaho
Copy link

djaho commented Dec 8, 2018

Thanks for your comment Sam. Right now, I am personally not planning on migrating to the new rest api, as the current one works good enough for me and I find it much easier to modify it for my purposes.
And also, I think I had some issues (I don't remember what exactly) installing the new REST API to phplist (v3.3.5). And I remember that it was just a lot easier to install the old version of REST API ;)

@samtuke
Copy link
Contributor

samtuke commented Dec 8, 2018

@djaho OK, even though the REST API that you're using is no longer maintained, we would welcome pull requests with the improvements that you've made.

A new version of phpList will be released shortly which includes an automatic updater. In future releases that updater will allow installing the new REST API also, which should make it easier for you to set it up and try it out.

@djaho
Copy link

djaho commented Dec 8, 2018

@samtuke I will test my change for some more time and if all will be well, I will make a pull request. Even though this will be my fist Github pull request :)

Thanks for the info about the updater. I will definitely check the new rest api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants