EventSub webhook callback verification failed. Help me =(

Please help me.
I’m trying to set up a callback to subscribe to EventSub.
I am using framework yii2 (PHP).
What am I doing wrong?

I test my callback and get the following:

Summary
PS C:\Users\ma110y> twitch event trigger update-redemption -F https://tagged-play.ru/twitch-callback -s c3eb4dc7c6da0ad20397fbaa244a04446c76e9d3df71b7c99fd1057b7102729c
✔ Request Sent. Received Status Code: 200
✔ Server Said: null
{"subscription":{"id":"137d104b-68eb-b00c-e322-b8961900cc41","status":"enabled","type":"channel.channel_points_custom_reward_redemption.update","version":"1","condition":{"broadcaster_user_id":"17390441"},"transport":{"method":"webhook","callback":"null"},"created_at":"2023-01-18T21:28:25.1561829Z","cost":0},"event":{"id":"137d104b-68eb-b00c-e322-b8961900cc41","broadcaster_user_id":"17390441","broadcaster_user_login":"testBroadcaster","broadcaster_user_name":"testBroadcaster","user_id":"40725345","user_login":"testFromUser","user_name":"testFromUser","user_input":"Test Input From CLI","status":"unfulfilled","reward":{"id":"8eca1920-3776-eb6c-dbda-61d044f67e09","title":"Test Reward from CLI","cost":150,"prompt":"Redeem Your Test Reward from CLI"},"redeemed_at":"2023-01-18T21:28:25.1561829Z"}}
PS C:\Users\ma110y>

On my site I see fallowing:

Summary

    [event] => stdClass Object
        (
            [id] => 137d104b-68eb-b00c-e322-b8961900cc41
            [broadcaster_user_id] => 17390441
            [broadcaster_user_login] => testBroadcaster
            [broadcaster_user_name] => testBroadcaster
            [user_id] => 40725345
            [user_login] => testFromUser
            [user_name] => testFromUser
            [user_input] => Test Input From CLI
            [status] => unfulfilled
            [reward] => stdClass Object
                (
                    [id] => 8eca1920-3776-eb6c-dbda-61d044f67e09
                    [title] => Test Reward from CLI
                    [cost] => 150
                    [prompt] => Redeem Your Test Reward from CLI
                )

            [redeemed_at] => 2023-01-18T21:28:25.1561829Z
        )

Next, I register a webhook and get the following:

Summary
array(4) {                                                                                                                                                                                                                                                                                                                 
  ["data"]=>                                                                                                                                                                                                                                                                                                               
  array(1) {                                                                                                                                                                                                                                                                                                               
    [0]=>                                                                                                                                                                                                                                                                                                                  
    array(8) {                                                                                                                                                                                                                                                                                                             
      ["id"]=>                                                                                                                                                                                                                                                                                                             
      string(36) "90e92aed-b2d2-4b88-963d-19e564a56df1"                                                                                                                                                                                                                                                                    
      ["status"]=>                                                                                                                                                                                                                                                                                                         
      string(37) "webhook_callback_verification_pending"                                                                                                                                                                                                                                                                   
      ["type"]=>                                                                                                                                                                                                                                                                                                           
      string(14) "channel.update"                                                                                                                                                                                                                                                                                          
      ["version"]=>                                                                                                                                                                                                                                                                                                        
      string(1) "1"                                                                                                                                                                                                                                                                                                        
      ["condition"]=>                                                                                                                                                                                                                                                                                                      
      array(1) {                                                                                                                                                                                                                                                                                                           
        ["broadcaster_user_id"]=>                                                                                                                                                                                                                                                                                          
        string(9) "798748369"                                                                                                                                                                                                                                                                                              
      }                                                                                                                                                                                                                                                                                                                    
      ["created_at"]=>                                                                                                                                                                                                                                                                                                     
      string(30) "2023-01-18T21:21:40.969961007Z"                                                                                                                                                                                                                                                                          
      ["transport"]=>                                                                                                                                                                                                                                                                                                      
      array(2) {                                                                                                                                                                                                                                                                                                           
        ["method"]=>                                                                                                                                                                                                                                                                                                       
        string(7) "webhook"                                                                                                                                                                                                                                                                                                
        ["callback"]=>                                                                                                                                                                                                                                                                                                     
        string(38) "https://tagged-play.ru/twitch-callback"                                                                                                                                                                                                                                                                
      }                                                                                                                                                                                                                                                                                                                    
      ["cost"]=>                                                                                                                                                                                                                                                                                                           
      int(0)                                                                                                                                                                                                                                                                                                               
    }                                                                                                                                                                                                                                                                                                                      
  }                                                                                                                                                                                                                                                                                                                        
  ["total"]=>                                                                                                                                                                                                                                                                                                              
  int(1)                                                                                                                                                                                                                                                                                                                   
  ["max_total_cost"]=>                                                                                                                                                                                                                                                                                                     
  int(10000)                                                                                                                                                                                                                                                                                                               
  ["total_cost"]=>                                                                                                                                                                                                                                                                                                         
  int(0)                                                                                                                                                                                                                                                                                                                   
}      

on my server i see this:

Summary
stdClass Object
(
    [subscription] => stdClass Object
        (
            [id] => 90e92aed-b2d2-4b88-963d-19e564a56df1
            [status] => webhook_callback_verification_pending
            [type] => channel.update
            [version] => 1
            [condition] => stdClass Object
                (
                    [broadcaster_user_id] => 798748369
                )

            [transport] => stdClass Object
                (
                    [method] => webhook
                    [callback] => https://tagged-play.ru/twitch-callback
                )

            [created_at] => 2023-01-18T21:21:40.969961007Z
            [cost] => 0
        )

    [challenge] => 7oju4NLCrEwRNYgHNVAzYXf_brHJR4J5iNDaiHZI2Qs
)

But when I send /helix/eventsub/subscriptions, I get webhook_callback_verification_failed

Summary
{
    "total": 1,
    "data": [
        {
            "id": "90e92aed-b2d2-4b88-963d-19e564a56df1",
            "status": "webhook_callback_verification_failed",
            "type": "channel.update",
            "version": "1",
            "condition": {
                "broadcaster_user_id": "798748369"
            },
            "created_at": "2023-01-18T21:21:40.969961007Z",
            "transport": {
                "method": "webhook",
                "callback": "https://tagged-play.ru/twitch-callback"
            },
            "cost": 0
        }
    ],
    "max_total_cost": 10000,
    "total_cost": 0,
    "pagination": {}
}

My code:

Summary
public function actionIndex()
    {
        \Yii::$app->response->format = Response::FORMAT_JSON;
        \Yii::$app->response->statusCode = 200;


        $folder =  \Yii::getAlias('@app/runtime/');

        file_put_contents($folder . '/payload.txt', file_get_contents('php://input'), FILE_APPEND);

        $incoming_payload = json_decode(file_get_contents('php://input'));

        file_put_contents($folder . '/payload_json.txt', '<pre>' . print_r($incoming_payload, true). '</pre>', FILE_APPEND);


        $headers = '<pre>' . print_r(getallheaders(), true) . '</pre>';

        file_put_contents($folder. '/' .time() . '_HEADERS.txt', $headers);

        if(isset($_GET) && !empty($_GET)) {
            $get = '<pre>' . print_r($_GET, true) . '</pre>';
            file_put_contents($folder. '/' .time() . '_GET.txt', $get);
        }
        if(isset($_POST) && !empty($_POST)){
            $post = '<pre>' . print_r($_POST, true) . '</pre>';
            file_put_contents($folder. '/' .time() . '_POST.txt', $post);
        }
    }

Callback link - https://tagged-play.ru/twitch-callback
I return 200 code as required by the documentation and do not output/send anything in response.
I have an ssl certificate and port 443 is available. What am I doing wrong?

I don’t see you responding to the challenge anywhere. When you subscribe to an EventSub over webhooks, Twitch will send you a challenge, as you can see in one of your summaries [challenge] => 7oju4NLCrEwRNYgHNVAzYXf_brHJR4J5iNDaiHZI2Qs

When Twitch sends that to you, you need to respond with a 200 status AND that challenge, which in that case would be 7oju4NLCrEwRNYgHNVAzYXf_brHJR4J5iNDaiHZI2Qs. If your server doesn’t send that challenge back, it fails the verification process.

You can also use the TwitchCLI to test your Callback

I did so and the result is

twitch event verify-subscription cheer -F https://tagged-play.ru/twitch-callback
✗ Invalid response. Received null as body, expected 0f4f2e05-42b1-e6a7-4e2e-ebbf7e7c8aad
✗ Invalid content-type header. Received type application/json with charset UTF-8. Expecting text/plain.
✔ Valid status code. Received status 200

Which as you can see is incorrect as you don’t echo back the challenge as dist notes

Thanks a lot. I succeeded =)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.