Giter Site home page Giter Site logo

Comments (12)

meluvalli avatar meluvalli commented on June 26, 2024

Hmm. Ok. Found the issue. It appears on line 120 you have:

is_us_region=False

This hard codes it to say it's not US. I change it to True and then it goes to the US site correctly. Now for my next issue... Once I login, it just goes to a blank page and then nothing happens... Python doesn't continue and just sits there. Should I create a new issue for this?

from carelink-python-client.

ondrej1024 avatar ondrej1024 commented on June 26, 2024

I can fix the hardcoded region selection (it was used for testing and then I forgot about it).
Unfortunately I don't have a US Carelink account, so I don't know how to debug this. But any contribution is welcome.

from carelink-python-client.

meluvalli avatar meluvalli commented on June 26, 2024

Hmm. Ok. Well, after you login, what should happen exactly? I know it suppose to generate the logindata.json... But is FireFox suppose to go to a blank page? Is it suppose to close FireFox automatically after it's done?

I was using the v1 successfully for a while now... However, now, when I use V1, it can't refresh the auth code. It give 403 error. I'm assuming something changed on Medtronic's side :(. So, I have to update the auth_token manually every 30 minutes for it to work, and obviously, that's not realistically doable :(

from carelink-python-client.

ondrej1024 avatar ondrej1024 commented on June 26, 2024

As for the login script, you may need to close Firefox if it's already running or nothing happens.

from carelink-python-client.

meluvalli avatar meluvalli commented on June 26, 2024

Well, I don't know much about programming in Python, but the line it's getting stuck on is 108:

for request in driver.requests:

It loops the sleep command, but I am assuming request is null or empty, so it never gets further on the do_captcha... It never get's the the line "if request.response: " (Line 109). It just loops between line 108 and 120. I am not sure why this would be. I'm running FireFox 124.0 (64-bit).

I'm guessing webdriver isn't working correctly in it.

My Test Code I tried was this:

def do_captcha(url, redirect_url):
	driver = webdriver.Firefox()
	driver.get(url)

	while True:
		print("Waiting to do For Statement...")
		for request in driver.requests:  
			print("Waiting for request.response")
			if request.response:  
				print(request.response.status_code)
				if request.response.status_code == 302:
					if "location" in request.response.headers:
						location = request.response.headers["location"]
						if redirect_url in location:
							code = re.search(r"code=(.*)&", location).group(1)
							state = re.search(r"state=(.*)", location).group(1)
							driver.quit()
							return (code, state)
		sleep(0.1)

The output just looped over and over again "Waiting to do For Statement...". Which tells me it never gets the request in driver.requests.

And again, it does open FireFox for me correctly... So, I know webdriver is working in firefox.

from carelink-python-client.

ondrej1024 avatar ondrej1024 commented on June 26, 2024

There has been an issue reported with the login script reported in issue #15. This is probably not related but maybe it gives you some clue.

from carelink-python-client.

ondrej1024 avatar ondrej1024 commented on June 26, 2024

This is the Firefox window which opens on my PC when running carelink_carepartner_api_login.py with is_us_region=True. I am running this on Ubuntu Linux.

image

from carelink-python-client.

meluvalli avatar meluvalli commented on June 26, 2024

That's what mine looks like, but after I sign in, I get a blank white page, and nothing happens.
I read the info from #15, however, I don't understand how I would update the geckodriver on Windows. I downloaded the geckodriver.exe, but I don't have another geckodriver.exe file to replace to upgrade it... :(

from carelink-python-client.

meluvalli avatar meluvalli commented on June 26, 2024

Ok, I used https://stackoverflow.com/questions/41190989/how-do-i-install-geckodriver and downloaded the geckodriver. Then placed the exe in my Python directory. In My case it is "C:\Program Files\Python312". I am still having the same problem. I verified Selenium is installed in Python as well. It's version 4.19.0.

from carelink-python-client.

ondrej1024 avatar ondrej1024 commented on June 26, 2024

I guess we need some feedback of other Carelink user with a US account to find out if this is a general issue or just your setup. As said before, I cannot verify any of this, not having a US Carelink account, nor running Windows on my PC.

from carelink-python-client.

meluvalli avatar meluvalli commented on June 26, 2024

I finally got it!

So, here is what I did...

  1. Edited the carelink_carepartner_api_login.py file.
    Added the following lines on line 52: This allows for auto install of GeckoDriver.
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

Changed is_us_region=False to is_us_region=True. (This was needed as I'm in the US not EU)

  1. Installed Python 3.12.2 x64
  2. Installed FireFox 124.0 x64
  3. I rebooted my machine at this point. Not sure if it's required or not.
  4. Ran the following commands to install all pre-requisites for the carelink_carepartner_api_login.py
pip.exe install requests
pip.exe install curlify
pip.exe install pyOpenSSL
pip.exe install selenium-wire

# The below lines are new for allowing auto-install of GeckoDriver.
pip.exe install setuptools
pip.exe install packaging
pip.exe install webdriver-manager
  1. Ran the script
python.exe carelink_carepartner_api_login.py

FireFox opened to Medtronic, I was able to login, then the screen closed automatically and the logindata.json file was generated!

Hope these DETAILED instructions help others if they have issues!

Side note: This is on Windows 11 Build 26085.1
Below are the versions of packages installed:

requests==2.31.0
curlify==2.2.1
pyOpenSSL==24.1.0
selenium-wire==5.1.0
setuptools==69.2.0
packaging==24.0
webdriver-manager==4.0.1

Script installed GeckoDriver v0.34.0

from carelink-python-client.

ondrej1024 avatar ondrej1024 commented on June 26, 2024

Good to hear you worked it out.

I will add an option to the login script to select US region. But it seems that one can run into quite some trouble installing the correct script dependencies. I don't know how this could be improved.

from carelink-python-client.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.