wp-cli-login-command icon indicating copy to clipboard operation
wp-cli-login-command copied to clipboard

The attempted magic login has expired or already been used.

Open blairwigleyactu opened this issue 3 years ago • 4 comments

So I've got a bunch of commands that are run via ssh/paramiko on some WP Engine sites.

If I run: cd ~/sites/mysite/; wp login create [email protected] --url-only --redirect-url=/wp-admin/admin.php?page=theme-base-theme-settings directly from ssh it'll generate a usable url, but for some reasons when I run the command via my paramiko script it'll generate a url that displays The attempted magic login has expired or already been used. - the commands are exactly the same. There's a bunch of vanilla and custom wp cli commands that run fine via paramiko so it's not a universal issue.

Really weird, I assume it's some quirk with how paramiko works, but just wondering if you have any idea what could be happening?

blairwigleyactu avatar Jul 14 '22 05:07 blairwigleyactu

Ok weird: adding --expires=0 to the command made it work. Very odd. 🤷‍♀️

blairwigleyactu avatar Jul 14 '22 06:07 blairwigleyactu

Using --expires=0 will create a login link that will not expire. Glad you got it to work though! I'm not sure why it wouldn't work for you but happy to try to help debug it.

Do you have anything in your script that manipulates transients by chance? You might try inspecting what you have in there after creating one to see what the expiration looks like (without the added flag that is):

wp transient list --search="wp_cli_login*"

aaemnnosttv avatar Jul 25 '22 22:07 aaemnnosttv

I had this problem, and it was because of a fancy clipboard manager app I use... when I copied the link out of the terminal for testing, this app was visiting the URL to scrape some data and therefore invalidating it.

And --expires=0 doesn't do anything in this case, for obvious reasons.

So watch out for anything that might be visiting or pre-fetching the link!

careybaird avatar Sep 12 '22 16:09 careybaird

Thanks for sharing your experience @careybaird !

watch out for anything that might be visiting or pre-fetching the link!

This is a known issue, see https://github.com/aaemnnosttv/wp-cli-login-command/issues/1 😉

aaemnnosttv avatar Sep 12 '22 20:09 aaemnnosttv