From 9e1bb955fac94b5a320be9174048430c8843c90f Mon Sep 17 00:00:00 2001 From: k__nard Date: Thu, 8 Dec 2022 15:39:03 -0700 Subject: [PATCH] updating twitch to latest api (Helix) Summary: api doc : https://dev.twitch.tv/docs/api/reference oauth2 doc : https://dev.twitch.tv/docs/authentication Test Plan: I have successfully setup OAuth2 authentication against Twitch Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Tags: #auth Maniphest Tasks: T15122 Differential Revision: https://we.phorge.it/D25056 --- src/future/twitch/PhutilTwitchFuture.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/future/twitch/PhutilTwitchFuture.php b/src/future/twitch/PhutilTwitchFuture.php index 9dc06c34..cc59d6b3 100644 --- a/src/future/twitch/PhutilTwitchFuture.php +++ b/src/future/twitch/PhutilTwitchFuture.php @@ -47,12 +47,12 @@ final class PhutilTwitchFuture extends FutureProxy { } $uri = new PhutilURI('https://api.twitch.tv/'); - $uri->setPath('/kraken/'.ltrim($this->action, '/')); - $uri->replaceQueryParam('oauth_token', $this->accessToken); + $uri->setPath('/helix/'.ltrim($this->action, '/')); $future = new HTTPSFuture($uri); $future->setData($this->params); $future->setMethod($this->method); + $future->addHeader('Authorization', 'Bearer '.$this->accessToken); // NOTE: This is how the Twitch API is versioned. $future->addHeader('Accept', 'application/vnd.twitchtv.2+json'); @@ -87,7 +87,7 @@ final class PhutilTwitchFuture extends FutureProxy { throw new Exception(pht('Received error from Twitch: %s', $error)); } - return $data; + return $data['data'][0]; } }