I'm building on Python the "User-initiated Calls" handling by WhatsApp Cloud API:
I successfully completed the Prerequisites steps to enable the voice calling in my WhatsApp app: "Cloud API Calling | Get Started | Step 1: Prerequisites".
The WebRTC / SDP connection setup is implemented using aiortc:
async def handle_call_offer(self, sdp_req, wa_call_id):
''' accept incoming call request '''
player = MediaPlayer(os.path.join(os.path.dirname(__file__), 'alstand/sample.mp3'))
pc = RTCPeerConnection() # create WebRTC peer connection
pc.addTrack(player.audio)
offer = RTCSessionDescription(sdp=sdp_req['sdp'], type=sdp_req['sdp_type'])
await pc.setRemoteDescription(offer)
answer = await pc.createAnswer() # Create an answer
await pc.setLocalDescription(answer)
''' send accept WhatsApp call request '''
payload = json.dumps({
'messaging_product': 'whatsapp',
'call_id': wa_call_id,
'action': 'accept',
'session': {
'sdp_type': 'answer',
'sdp': pc.localDescription.sdp # re-use respone's sdp
}
})
response = requests.request('POST', f'{self.API_URL}/calls', headers=self.headers, data=payload)
return pc.localDescription.sdp
Eventually, the incoming call request is successfully accepted, the response is sent, but an error is returned to the incoming call acceptance request:
// 400 Bad Request
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_data": {
"messaging_product": "whatsapp",
"details": "Fingerprint algo is not SHA256"
},
"error_subcode": 2494010,
"is_transient": false,
"error_user_title": "Parameter Invalid",
"error_user_msg": "Check input parameters and retry the request",
"fbtrace_id": "ApaWkAViZR1ZYOg3XpILtzj"
}
}
I checked the request's SDP format and see that it does contain the SHA256 fingerprint:
v=0
...
a=fingerprint:sha-256 AB:27:4E:3F:...
a=fingerprint:sha-384 CE:BD:D0:63:...
a=fingerprint:sha-512 94:98:EF:02:...
...
What could I miss in my implementation or initial config so the SDP offer is not accepted?
I was facing the exact same problem today. So for unknown reason WhatsApp is pretty nerdy about its requests formatting. WhatsApp expects capital letters in SDP:
a=fingerprint:SHA-256 AB:27:4E:3F:...
Moreover, replacing sha-512 and sha-384 with capital letters also doesn't work. Consider deleting these lines for good, as it is the only option that worked for me.