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

Specify port leads to error. Make port optional? #120

Open
botkero opened this issue May 12, 2022 · 0 comments
Open

Specify port leads to error. Make port optional? #120

botkero opened this issue May 12, 2022 · 0 comments

Comments

@botkero
Copy link

botkero commented May 12, 2022

Hello,

I found this Python driver a few days ago. However, I am having some difficulties getting this driver to work. The login process always fails for me ( using personal access token). The error message looks very similar to the one in this closed thread.

Unfortunately you can't find anything on the internet, so today I decided to debug the source code and I found at least a solution for me.

I use the code from @IronVenom

from mattermostdriver import Driver

driver_options = {
        'url': "url",
        'token':'token'
}

driver = Driver(driver_options)

print("Authenticating...")
driver.login()
print("Successfully authenticated.")

As I said the error message is the same and I therefore save the error message see closed thread.

I noticed that to my URL regardless of whether I specify a port, the port is appended. So I wanted to know what happens if I leave that out.

My quick solution is:

 # client.py line 42

@staticmethod
def _make_url(scheme, url, port, basepath):
	if port == False:
		return f"{scheme:s}://{url:s}{basepath:s}"
	return f"{scheme:s}://{url:s}:{port:d}{basepath:s}"

The call to avoid having to specify the port would then look like this:

from mattermostdriver import Driver

driver_options = {
        'url': "url",
        'token':'token'
        'port': False,
}

driver = Driver(driver_options)

print("Authenticating...")
driver.login()
print("Successfully authenticated.")

With this small change at least the login process works. I haven't had the chance to test other calls via the API/Driver yet.

I can't judge myself if my implementation is good/bad. It only works for me. I myself am still learning Python and am not familiar with such developments.

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

1 participant