The issue

I am trying to setup a flow with WhatsApp Business API but am unable to complete the decryption of the key as part of the endpoint healthcheck.

I get this error: Encryption/decryption failed

in decrypt_request     aes_key = private_key.decrypt(encrypted_aes_key, OAEP(mgf=MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None)) ValueError: Encryption/decryption failed. 

How to reproduce the issue

Below are the steps I followed, as per the docs here and here:

  1. Set up the flows endpoint.

  2. Generate 2048-bit RSA Key Pair.

openssl genrsa -des3 -out private.pem 2048 

The key looks like this:

-----BEGIN ENCRYPTED PRIVATE KEY----- AAA........ BBB.... .... -----END ENCRYPTED PRIVATE KEY----- 
  1. Export the RSA Public Key to a file:
openssl rsa -in private.pem -outform PEM -pubout -out public.pem 
  1. Set business public key.
curl -X POST \   'https://graph.facebook.com/v21.0/PHONE_NUMBER_ID/whatsapp_business_encryption' \   -H 'Authorization: Bearer ACCESS_TOKEN' \   -H 'Content-Type: application/x-www-form-urlencoded' \   --data-urlencode 'business_public_key=-----BEGIN PUBLIC KEY----- AAA BBB CCC -----END PUBLIC KEY-----' 
  1. Create encryption/decryption code:
import json import os from base64 import b64decode, b64encode from cryptography.hazmat.primitives.asymmetric.padding import OAEP, MGF1, hashes from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes from cryptography.hazmat.primitives.serialization import load_pem_private_key from fastapi import HTTPException, Request import logging # Load the private key string # PRIVATE_KEY = os.environ.get('PRIVATE_KEY') PRIVATE_KEY_PATH = "./private.pem" with open(PRIVATE_KEY_PATH, "rb") as pem_file:          PRIVATE_KEY = pem_file.read().decode("utf-8") async def data(request: Request):     try:         # Parse the request body         body = json.loads(await request.body())         logging.info(f"body = {body}")         # Read the request fields         encrypted_flow_data_b64 = body['encrypted_flow_data']         encrypted_aes_key_b64 = body['encrypted_aes_key']         initial_vector_b64 = body['initial_vector']         decrypted_data, aes_key, iv = await decrypt_request(             encrypted_flow_data_b64, encrypted_aes_key_b64, initial_vector_b64)         print(decrypted_data)         # Return the next screen & data to the client         response = {             "screen": "SCREEN_NAME",             "data": {                 "some_key": "some_value"             }         }         # Return the response as plaintext         return await encrypt_response(response, aes_key, iv)     except Exception as e:         print(e)         raise HTTPException(status_code=500, detail="Internal Server Error") async def decrypt_request(encrypted_flow_data_b64, encrypted_aes_key_b64, initial_vector_b64):     flow_data = b64decode(encrypted_flow_data_b64)     iv = b64decode(initial_vector_b64)     # Decrypt the AES encryption key     encrypted_aes_key = b64decode(encrypted_aes_key_b64)     private_key = load_pem_private_key(         PRIVATE_KEY.encode("utf-8"), password=os.getenv("PASSPHRASE").encode('utf-8'))     aes_key = private_key.decrypt(encrypted_aes_key, OAEP(         mgf=MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None))     # Decrypt the Flow data     encrypted_flow_data_body = flow_data[:-16]     encrypted_flow_data_tag = flow_data[-16:]     decryptor = Cipher(algorithms.AES(aes_key),                        modes.GCM(iv, encrypted_flow_data_tag)).decryptor()     decrypted_data_bytes = decryptor.update(         encrypted_flow_data_body) + decryptor.finalize()     decrypted_data = json.loads(decrypted_data_bytes.decode("utf-8"))     return decrypted_data, aes_key, iv async def encrypt_response(response, aes_key, iv):     # Flip the initialization vector     flipped_iv = bytearray()     for byte in iv:         flipped_iv.append(byte ^ 0xFF)     # Encrypt the response data     encryptor = Cipher(algorithms.AES(aes_key),                        modes.GCM(flipped_iv)).encryptor()     return b64encode(         encryptor.update(json.dumps(response).encode("utf-8")) +         encryptor.finalize() +         encryptor.tag     ).decode("utf-8") 
  1. Trigger the health check from https://business.facebook.com/latest/whatsapp_manager/flows

Can someone tell me what I'm doing wrong?

Apologies for what should be a basic question, but i've hit the end of my rope. I'm trying to resurrect an old project that used the instagram API to search for posts based on a given hashtag (long before the graph API). Previously this was very simple to go to the developer page, apply for an API token and then hit the URL. Things have changed massively with the newer graph endpoints and i'm struggling to understand what to do, and hitting bugs/issues with facebooks developer tooling at every step of the way

What I want to do:
Given a hashtag string, find the hashtag id and then poll this endpoint once, lets say, every 30 seconds: https://developers.facebook.com/docs/instagram-platform/instagram-graph-api/reference/ig-hashtag/recent-media

Later I want to try search for comments on these posts too, but that will depend on a few things as I go

Whats wrong:
Every attempt to make use of this (by creating an app on the dashboard, waiting for verification, and generating a token) just keeps returning that the token is invalid, or the account is not valid. Lots of the documentation seems to be out of date and referencing an older setup. Some docs say that this endpoint requires a business account + business app. Although I didn't want to, I migrated my personal instagram account to a business account, and tried to create a business app which is an extremely convoluted process requiring business verification, for simple access to an endpoint. I don't have a business so I can't fully complete this process.

I've tried to ask for help via the meta developer community, but it won't load for many days now:

If I try jump directly into the instagram community section via google, it will load, but I keep getting a popup to say that my profile is incomplete. If I click to complete, it doesn't do anything. If I dismiss it, it just keeps popping up. If I go directly to my profile, it won't let me add anything. The community page won't let me do anything without the profile

I've tried to report a bug via the tool, but it tells me I can't do that here, as this bugs should be directed to the community portal ... which I can't get into

... this has been an EXTREMELY painful experience over the course of several days which has me regretting trying to use instagram again

What I need:
Can someone please provide step-by-step instructions on what I need to do to create the appropriate access token to hit this endpoint. Including the process of creating whichever type of developer app I need in the dashboard.

I don't have a server, a domain, a business, or even a project name ... i'm simply trying to generate a once off access token, hit this endpoint via a project running on my local machine to experiment with an idea. Thanks

Hello, I have created a facebook account with email ID: [...] and have add the phone number: [...] in the whatsapp business platform. Since the facebook account didn't meet the community standard, it is disabled permanently now after appeal. Now I am not able to remove the phone number: [...] from the whatsapp business platform since the facebook account is disabled. Please help to remove the phone number from the whatsapp business platform which associated with the disabled facebook account.

I have a Custom Audience that's being generated from a customer list. That customer list is composed of both customer's phone numbers and emails, but not necessarily both a phone number and an email linked to a single customer, so I don't want to use multi-key matching. I want to use the usersreplace endpoint to update this list on a regular basis. I want to go through all the phones and add them in a single session and then go through all the emails and add them in that same session.
I am able to successfully add all of the first schema type. But when I get to the second schema type, I get a (#2650) service error. I believe this is due to using a second, different schema type, because when I switch to use the email first, I get the same error when I start trying to add the phones.