Skip to content

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

@botkero

Description

@botkero

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions