/
WhatsApp Access token Decode

WhatsApp Access token Decode

What are we trying to achieve?

  1. A user enters the access token in the input fields, following API will be called

curl --location 'http://localhost:8080/_ah/api/esb/v1/accessTokenVerify?accessToken=EAANZApwNQDqUBO7UutelOU0j6oZAfBB6ZBDIPsun933JuKUXxVR0ddpUdLXeB2eH3JHAYo9zbx8QMXd26MCnD5h8PRBxGsicyY7Fq1RD6NlfSjMCoa5BdGsk7NczYzeiOKN3VyMUMZADOub5xZCwp1PZAB4cgWQszDtZCfRHGSAG4PYmLbPZCvpHbssbhozo03Svr9OZBHE4i6zRm3Swv5Xz7JhYyfZA6d' \ --header 'Cookie: JSESSIONID=YhyF-9V7GjcEiUmQulh1HQ.node0'
  1. We call meta API:

curl --location 'https://graph.facebook.com/debug_token?input_token=EAANZApwNQDqUBO6zX9aAqg7ED2PmZBmG5ZCC3tV9DSvah5xfcBVyt8CSiZCdDJoWyOwjvZAbZBax3qVXAZCcdUx5onDBvQltI1axudB2dlqd08LjZBQd7bTDI2TRzizH4nOvAgJdkhS7lQlBKP3TYM3ZA1mc5IFBteiHxTlGpCMwceckBKEel4okyYv8cvuLGmZA9GVXZA8ZCZAY9JdSCer1RgoSMMjT9M6cZD' \ --header 'Authorization: Bearer EAANZApwNQDqUBO6zX9aAqg7ED2PmZBmG5ZCC3tV9DSvah5xfcBVyt8CSiZCdDJoWyOwjvZAbZBax3qVXAZCcdUx5onDBvQltI1axudB2dlqd08LjZBQd7bTDI2TRzizH4nOvAgJdkhS7lQlBKP3TYM3ZA1mc5IFBteiHxTlGpCMwceckBKEel4okyYv8cvuLGmZA9GVXZA8ZCZAY9JdSCer1RgoSMMjT9M6cZD'
  1. Response from above:

{ "data": { "app_id": "942998780120741", "type": "USER", "application": "Eshopbox", "data_access_expires_at": 1697453229, "expires_at": 1691553600, "is_valid": true, "scopes": [ "business_management", "whatsapp_business_management", "whatsapp_business_messaging", "public_profile" ], "granular_scopes": [ { "scope": "business_management" }, { "scope": "whatsapp_business_management", "target_ids": [ "100540503108666" ] }, { "scope": "whatsapp_business_messaging", "target_ids": [ "100540503108666" ] } ], "user_id": "136331582832331" } }
  1. It will fetch WhatsApp business account Id from the above response

  2. Save the key in “wabaId” and return

Final response from Eshop API:

{ "wabaId": "100540503108666" }
  1. On the basis of the above response, another API will be called:

curl --location 'http://localhost:8080/_ah/api/esb/v1/phoneNumbers?accessToken=EAANZApwNQDqUBO7UutelOU0j6oZAfBB6ZBDIPsun933JuKUXxVR0ddpUdLXeB2eH3JHAYo9zbx8QMXd26MCnD5h8PRBxGsicyY7Fq1RD6NlfSjMCoa5BdGsk7NczYzeiOKN3VyMUMZADOub5xZCwp1PZAB4cgWQszDtZCfRHGSAG4PYmLbPZCvpHbssbhozo03Svr9OZBHE4i6zRm3Swv5Xz7JhYyfZA6d&wabaId=100540503108666' \ --header 'Cookie: JSESSIONID=YhyF-9V7GjcEiUmQulh1HQ.node0'
  1. Value whatsAppBusinessAccountId will be used to call another Meta API

curl --location 'https://graph.facebook.com/v17.0/100540503108666/phone_numbers' \ --header 'Authorization: Bearer EAANZApwNQDqUBO0pc5VJ4PanqG2CX104QKpw91FYEmExFG7uYbG1fLHTKLdz37ATKdmxzZAqn05xhRmqzlDam3pXsQXJnIRB4EJHCbJ2a33NVIgDhLaW67RXqum9Hpva8TKkJ9IO9046iIcpdQv2k7RpiZAdxrfkolyer96PSFUjarTZCw4IndhzwYvD2Ev0wasRuxAtdG3AKLQAlcIZCLYKdb5IZD'
  1. Store above response in Map<String, Object> and return

  2. Response from Eshop API call:

{ "data": [ { "display_phone_number": "15550512539", "quality_rating": "GREEN", "verified_name": "Test Number", "id": "105339412622627", "code_verification_status": "NOT_VERIFIED" } ], "paging": { "cursors": { "before": "QVFIUk9nV29CUDdwbzFYUmZAQM2gwTXZAxaDFMNXI5TTg4WDFUZAndUOUhCUzA2UUJ5aXpCY0lWOVRDZAk94dVhFNEJGWkUZD", "after": "QVFIUk9nV29CUDdwbzFYUmZAQM2gwTXZAxaDFMNXI5TTg4WDFUZAndUOUhCUzA2UUJ5aXpCY0lWOVRDZAk94dVhFNEJGWkUZD" } }, "response": "success" }
  1. list of phone numbers will be returned from the above.

Add label

Related content