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

Logging in to geocaching.com not working (Captcha problem) #157

Open
gotiniens opened this issue Sep 25, 2020 · 5 comments
Open

Logging in to geocaching.com not working (Captcha problem) #157

gotiniens opened this issue Sep 25, 2020 · 5 comments

Comments

@gotiniens
Copy link

as discussed @ cgeo/cgeo#9056

The login page of geocaching.com for some IP's adds an Captcha, when this happens pycaching fails with

    raise LoginFailedException("Cannot login to the site "
pycaching.errors.LoginFailedException: Cannot login to the site (probably wrong username or password).

A solution is to use an different IP, but that is sometimes easier said than done.

@FriedrichFroebel
Copy link
Collaborator

I just had a quick look at the c:geo discussions on this issue. At the moment there are two possible solutions for this:

  • At least report a dedicated error message if a captcha is required. This would not solve the issue itself, but would make more clear what went wrong.
  • Allow the user to pass its own login cookie data (which would require some experience from the user).

@gotiniens
Copy link
Author

If the second point is a problem depends on the use case. for my use case: I just want to process some data for my own trackable. The code will probally not be released to the public. Passing the login cookie data will not be a problem

@FriedrichFroebel
Copy link
Collaborator

The Geocaching class seems to support passing session objects already, where you could provide the corresponding cookies. But it seems like the login method and the actual request handlers cannot handle this case for now - feel free to submit a fix for this.

@gotiniens
Copy link
Author

I have an working proof of concept in my forked repo: https://github.com/gotiniens/pycaching/tree/feature-use-token-for-requests

Do you care to give any further hints en tips before I create an merge request? Usage is very simple, instead of the normal pycaching.login(username, password) to initialize an geocaching object you use pycaching.login_with_token(token) to initialize the object.

You can get the token from the cookiestorage of your browser, it is the cookie called pskauth.

potentianly I have to add some handling for when the cookie is expirded and we get presented an new cookie. But I have been using my current token for a couple of weeks now, with no problem.

@FriedrichFroebel
Copy link
Collaborator

I somehow missed your last comment and just stumbled upon it when going through some of the open issues.

It usually is much easier if we discuss the remaining details inside the pull request when the corresponding code is directly visible. So please open a pull request if you are still interested in providing the enhancement.

What I have seen for now and probably should be changed:

  • Please add some logging like in the regular login method.
  • Why is the token nullable? This does not make much sense as we do not allow loading it from a file as for the username and password.
  • Please add a check for an already logged in user as for the regular login method.
  • The code style check will probably report some issues.
  • Maybe add some documentation on which cookie value to pass.
  • Is there some way for you to validate the correct behaviour through an automated test?

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

No branches or pull requests

2 participants