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

Unable to get refresh token with Firefox #6

Open
Kuba314 opened this issue Jun 16, 2023 · 4 comments
Open

Unable to get refresh token with Firefox #6

Kuba314 opened this issue Jun 16, 2023 · 4 comments

Comments

@Kuba314
Copy link

Kuba314 commented Jun 16, 2023

Describe the bug
I'm not familiar with selenium at all, but lidl-plus auth was reporting that I don't have firefox installed (I do). Removing executable_path, firefox_binary and firefox_profile arguments from webdriver.Firefox() in _init_firefox() fixed this issue.

Expected behavior
I'm supposed to get a refresh token.

Environment (please complete the following information):

  • Python-Version: 3.11
  • Release-Version: 0.2.6
  • OS: Fedora 37
  • Browser: Firefox and Chromium
  • Country: CZ
  • Language: cs
@stepva
Copy link

stepva commented Sep 12, 2023

I have a similar issue, but only when trying to run the auth from an installed package -> then it fails with Can't connect to web browser. Please install Chrome, Chromium or Firefox.
However, when I just clone the repo and run it locally with python3 lidlplus/__main__.py auth it works smoothly and without issues.
I'm running it on maxOS Monterey 12.5.1, installing the package via pip.
I'd try to look into it more, but it's difficult to debug, as it runs without issues locally. Figured I would at least write it here to help someone.

@MStrecke
Copy link

MStrecke commented Oct 6, 2023

Same problem here on my Linux box.

So I cloned the repo and tweaked it until it worked.

lidlplus uses Selenium. I'm also using Selenium in other projects. So, this package was already installed.
However the minimal Selenium program (two lines in a Python console) failed:

from selenium import webdriver
driver = webdriver.Firefox()

The geckodriver version (0.29.1) detected in PATH at /home/XXXX/bin/geckodriver might not be compatible with the detected firefox version (118.0.1); currently, geckodriver 0.33.0 is recommended for firefox 118.*, so it is advised to delete the driver in PATH and retry

The solution is simply enough: download the current geckodriver from the Mozilla project and try again. The two-liner worked.

After that I changed the lidl-plus source code in the file api.py. In the procedure _init_firefox I commented out three parameters that apparently don't exist anymore. (I tried using them in the two-liner and Python complained.)

        return webdriver.Firefox(
            # executable_path=GeckoDriverManager().install(),
            # firefox_binary="/usr/bin/firefox",
            options=options,
            # firefox_profile=profile,
        )

The superfluous parameters made the function call fail which was interpreted as "Firefox is not installed".

Please note that lidl-plus tries to connect to Chrome first before it tries to connect to Firefox and the timeout is about half a minute. So, be patient.

I temporarily changed options.headless to False three lines earlier in order to see the Firefox window pop up and to observe the interaction. You have to remember however that the PIN that you get on your mobile has to be entered in the command line window not into Firefox.

  • After cloning the repo change into its folder (in my case lidl-plus (with an -)).
  • From there change into lidlplus (without the -) and modify api.py.
  • Go back to the parent folder and call the script like
lidlplus/__main__.py auth
lidlplus/__main__.py --language=de --country=DE --refresh-token=XXXXXX receipt --all > data.json

@adithya995
Copy link

Will this work in a native app in headless mode? So far I was unsuccessful. It either fails to get a driver or selenium times out.

@Kuba314
Copy link
Author

Kuba314 commented Jan 19, 2024

@adithya995 What exactly do you mean by "native app" and "headless mode"? What are the exact errors you're getting when you say "fails to get a driver" and "selenium times out"?

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