+ }).Catch([=](HttpsConnection *rsp) mutable -> void {
+ promise.Reject(rsp);
+ });
+ return promise;
+}
+
+TwitchConnection::WebPromise TwitchConnection::GetClipAccessToken(const std::string &slug) {
+ WebPromise promise;
+ AuthorizedRequest("POST", "gql.twitch.tv", "/gql").Then([=](HttpsConnection *req) -> void {
+ req->SetHeader("Content-Type", "text/plain; charset=UTF-8");
+ req->SetHeader("Client-Id", "kimne78kx3ncx6brgo4mv6wki5h1ko");
+ Json::Value json(Json::arrayValue);
+ json[0]["extensions"]["persistedQuery"]["version"] = 1;
+ json[0]["extensions"]["persistedQuery"]["sha256Hash"] = "6fd3af2b22989506269b9ac02dd87eb4a6688392d67d94e41a6886f1e9f5c00f";
+ json[0]["operationName"] = "VideoAccessToken_Clip";
+ json[0]["variables"]["platform"] = "web";
+ json[0]["variables"]["slug"] = slug;
+ req->AddBody(json.toStyledString());
+ req->SetContentLength();
+ req->GetPromise()
+ .Then([this, promise](HttpsConnection *rsp) mutable -> void {
+ if (rsp->IsPositive()) {
+ Json::Value json = rsp->GetBodyJSON();
+ promise.Resolve(&json);
+ } else {
+ promise.Reject(rsp);
+ }
+ })
+ .Catch([=](HttpsConnection *rsp) mutable -> void {
+ promise.Reject(rsp);
+ });
+ }).Catch([=](HttpsConnection *rsp) mutable -> void {
+ promise.Reject(rsp);