Webhook hub.callback

I’m trying to set up webhook with go lang.
I can get 202 Accepted Response from Twitch, but can not get challenge response.

I guess hub.callback is wrong. I set hub.callback to localhost like following code.

values := url.Values{}
values.Add("first", "1")
values.Add("to_id", "USER_ID")

topicURL := "https://api.twitch.tv/helix/users/follows?" + values.Encode()
jsonStr := map[string]string{"hub.mode": "subscribe", "hub.topic": topicURL, "hub.lease_seconds": "864000", "hub.callback": "http://localhost:8080/callback"}

jsonValues, _ := json.Marshal(jsonStr)
url := "https://api.twitch.tv/helix/webhooks/hub?"
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonValues))
req.Header.Set("Client-ID", "CLIENT_ID")
req.Header.Set("Content-Type", "application/json")

client := new(http.Client)
resp, err := client.Do(req)

Can not use localhost for testing ?

The callback URL is what Twitch’s server makes a request to, and for Twitch, localhost would be the server itself. So no, you cannot use localhost as a callback URL. It must be a URL that will make it to your server/computer from the public internet.

Thanks for your fast reply. Okay, I understand. I try to test on public server.

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