gphotospy icon indicating copy to clipboard operation
gphotospy copied to clipboard

Authorize: errors with Address already in use

Open franTarkenton opened this issue 3 years ago • 0 comments

going through the auth flow and am getting the following error:

Traceback (most recent call last):
  File "/home/kjnether/proj/googlephoto/src/authorize.py", line 30, in <module>
    service = authorize.init(constants.CLIENT_SECRET_FILE)
  File "/home/kjnether/.local/share/virtualenvs/googlephoto-H2bFJvmL/lib/python3.8/site-packages/gphotospy/authorize.py", line 55, in init
    credentials = get_credentials(secrets)
  File "/home/kjnether/.local/share/virtualenvs/googlephoto-H2bFJvmL/lib/python3.8/site-packages/gphotospy/authorize.py", line 34, in get_credentials
    credentials = app_flow.run_local_server()
  File "/home/kjnether/.local/share/virtualenvs/googlephoto-H2bFJvmL/lib/python3.8/site-packages/google_auth_oauthlib/flow.py", line 457, in run_local_server
    local_server = wsgiref.simple_server.make_server(
  File "/usr/lib/python3.8/wsgiref/simple_server.py", line 154, in make_server
    server = server_class((host, port), handler_class)
  File "/usr/lib/python3.8/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/lib/python3.8/wsgiref/simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

Not sure what is using the default port on my machine. Either way to get around it wanted to use custom port for the authorization. Resolved the issue by modifying this line to

if 'GPHOTOSPY_AUTH_PORT' in os.environ:
    credentials = app_flow.run_local_server(os.environ['GPHOTOSPY_AUTH_PORT'])
else:
    credentials = app_flow.run_local_server()

franTarkenton avatar Feb 08 '22 03:02 franTarkenton