[GH-ISSUE #999] Authentication Flow failing due to host, port parsing #592

Open
opened 2026-02-27 23:23:32 +03:00 by kerem · 0 comments
Owner

Originally created by @christopherhastings on GitHub (Jul 6, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/999

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.

Originally created by @christopherhastings on GitHub (Jul 6, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/999 **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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#592
No description provided.