Skip to content

Authentication Flow failing due to host, port parsing  #999

@christopherhastings

Description

@christopherhastings

Describe the bug
In the Authentication flow, when trying to set up URL parsing based on a split ":", it cannot accommodate a port, which is necessary for self-authorization. I believe the get_host_port function is having difficulties parsing. 000

Your code

from six.moves.urllib_parse import parse_qsl, urlparse

def get_host_port(netloc):
    if ":" in netloc:
        host, port = netloc.split(":", 1)
        port = int(port)
    else:
        host = netloc
        port = None


url = 'http://127.0.0.1:8080'

redirect_info = urlparse(url)
redirect_host, redirect_port = get_host_port(redirect_info.netloc)

Share a complete minimal working example.

I do not have a working example

Expected behavior

 redirect_info = urlparse(self.redirect_uri)
 redirect_host, redirect_port = get_host_port(redirect_info.netloc)

    if (
            open_browser
            and redirect_host in ("127.0.0.1", "localhost")
            and redirect_info.scheme == "http"
    ):
        # Only start a local http server if a port is specified
        if redirect_port:
            return self._get_auth_response_local_server(redirect_port)

Output
TypeError: cannot unpack non-iterable NoneType object

Environment:

  • OS: [Mac]
  • Python version [3.7.7]
  • spotipy version [2.23.0]
  • Visual Studio

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions