pyatv icon indicating copy to clipboard operation
pyatv copied to clipboard

Authentication problem while trying to pair with mac music app

Open vsaintloup opened this issue 2 years ago • 0 comments

Describe the bug

Can't pair with macOS Music app (previously called iTunes). All my AppleTVs paired with no problem. Getting 400: Bad Request errors with 113 Connect call failed errors

Error log

Mac logs:

01:45:41.131688-0400	ControlCenter	[AirPlay] *** HTTP connection from 192.168.1.15:48666 to 192.168.1.2:7000 created [0x7F2D]
01:45:41.132498-0400	ControlCenter	[AirPlayReceiverKit] Created UI controller: 0xCE24
01:45:41.136071-0400	ControlCenter	[AirPlay] Request received from 192.168.1.15:48666 on connection [0x7F2D]
01:45:41.139630-0400	ControlCenter	[APReceiverRequestProcessorAirPlay] [0x8BA8] Control pair-setup PIN start
01:45:41.139691-0400	ControlCenter	[AirPlayError] airplayReqProcessor_isAllowedToConnectBasedOnACL:5217: false condition
01:45:41.139728-0400	ControlCenter	[AirPlayError] airplayReqProcessor_requestProcessPairSetupPINStart:3094: false condition
01:45:41.139765-0400	ControlCenter	[AirPlayError] _RequestProcessorHandler:4207: got error 1/0x1 EPERM
01:45:41.139799-0400	ControlCenter	[AirPlay] Sending response to 192.168.1.15:48666 on connection [0x7F2D]

HomeAssistant logs:

This error originated from a custom integration.

Logger: custom_components.apple_tv.config_flow
Source: custom_components/apple_tv/config_flow.py:389 
Integration: Apple TV 
First occurred: 1:19:22 AM (8 occurrences) 
Last logged: 1:45:41 AM

Authentication problem
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/__init__.py", line 33, in error_handler
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/airplay/auth/hap.py", line 43, in start_pairing
    await self.http.post("/pair-pin-start", headers=_AIRPLAY_HEADERS)
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/http.py", line 359, in post
    return await self.send_and_receive(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/http.py", line 412, in send_and_receive
    raise exceptions.HttpError(
pyatv.exceptions.HttpError: HTTP/1.1 method POST failed with code 400: Bad Request

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/apple_tv/config_flow.py", line 389, in async_pair_next_protocol
    await self.pairing.begin()
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/airplay/pairing.py", line 62, in begin
    return await error_handler(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/__init__.py", line 41, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: HTTP/1.1 method POST failed with code 400: Bad Request



This error originated from a custom integration.

Logger: custom_components.apple_tv.config_flow
Source: custom_components/apple_tv/config_flow.py:389 
Integration: Apple TV 
First occurred: 1:41:24 AM (1 occurrences) 
Last logged: 1:41:24 AM

Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/apple_tv/config_flow.py", line 389, in async_pair_next_protocol
    await self.pairing.begin()
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/airplay/pairing.py", line 59, in begin
    self.http = await http_connect(self.address, self.service.port)
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/http.py", line 556, in http_connect
    _, connection = await loop.create_connection(HttpConnection, address, port)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect
    return await fut
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.2', 7000)


How to reproduce the bug?

As soon as I see my newly discovered MacBookPro18,1, I click on «Configure», then I get this message:

You are about to add MacBook Pro de Vincent of type Unknown to Home Assistant.

Then I click Submit.

Then I get an empty Apple TV dialog box.

What is expected behavior?

Instead of an empty dialog box, I was expecting multiple verification codes to enter in the music app.

Operating System

Home Assistant OS 8.4

Python

3.10

pyatv

The one integrated to Home Assistant 2022.8.4

Device

macOS 12.5 / Music 1.2.5.7

Additional context

Capture d’écran, le 2022-08-15 à 17 06 02

vsaintloup avatar Aug 15 '22 21:08 vsaintloup