{"id":315,"date":"2022-03-11T19:54:12","date_gmt":"2022-03-11T19:54:12","guid":{"rendered":"https:\/\/www.unshapedadrian.co.uk\/blog\/?p=315"},"modified":"2022-03-11T19:54:12","modified_gmt":"2022-03-11T19:54:12","slug":"how-to-get-my-twitch-tools-working","status":"publish","type":"post","link":"https:\/\/www.unshapedadrian.co.uk\/blog\/code\/how-to-get-my-twitch-tools-working\/","title":{"rendered":"How to get my Twitch tools working"},"content":{"rendered":"\n<p>A long time back I wrote two tools which use standalone HTML and javascript to get data from Twitch, one was Box Art which I documented here: <a href=\"http:\/\/www.unshapedadrian.co.uk\/blog\/code\/how-to-add-the-current-games-box-art-to-your-scene-when-streaming-to-twitch\/\">Box Art Blog Post<\/a><\/p>\n\n\n\n<p>These tools have stopped working recently because Twitch changed a lot of requirements specifically to do with Authentication when accessing the APIs. I didn&#8217;t feel like there was a safe way to adapt my tools without causing problems for users, the data required by the API is a token that if accidentally shared could give someone else access to your Twitch channel data.<\/p>\n\n\n\n<p>All that said I did hack the tools myself so that I could continue using them and I want to share that process, it&#8217;s a few extra steps so you need to be pretty comfortable with editing code files. I&#8217;ll go through the process step by step. I&#8217;ll use the Box Art tool as a demo.<\/p>\n\n\n\n<p>First you need to get the latest version of the tool<\/p>\n\n\n\n<p>Twitch Box Art: <a href=\"https:\/\/github.com\/adrianschofield\/twitchboxart\">https:\/\/github.com\/adrianschofield\/twitchboxart<\/a><\/p>\n\n\n\n<p>Click on the green Code button and choose to download a Zip file.<\/p>\n\n\n\n<p>Unzip the files to wherever you want them and then open the scripts\\twitchboxart.js file in an editor, Notepad will work just fine.<\/p>\n\n\n\n<p>Now you need to grab a coffee and delve into the world of Twitch Developers.<\/p>\n\n\n\n<p>First go to this link in a new tab in your browser: <a href=\"https:\/\/twitchapps.com\/tokengen\/\">https:\/\/twitchapps.com\/tokengen\/<\/a><\/p>\n\n\n\n<p>Leave this tab open and start another tab with this address: <a href=\"https:\/\/dev.twitch.tv\/console\/apps\">https:\/\/dev.twitch.tv\/console\/apps<\/a><\/p>\n\n\n\n<p>If you are prompted to login at this stage then use your Twitch account to complete the steps<\/p>\n\n\n\n<p>Click on the purple Register Your Application button and then fill in the details as follows:<br><\/p>\n\n\n\n<p><strong>Name<\/strong> &#8211; can be anything but I believe you can&#8217;t use the name Twitch anywhere<\/p>\n\n\n\n<p><strong>OAuth Redirect Urls<\/strong> &#8211; you can get this from the first page you opened, it&#8217;s highlighted in red so just copy it from one tab to another https:\/\/twitchapps.com\/tokengen\/<br><strong>Category<\/strong> &#8211; choose Broadcaster Suite<br>Complete the Captcha and you should see this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"594\" src=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-1024x594.png\" alt=\"\" class=\"wp-image-317\" srcset=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-1024x594.png 1024w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-300x174.png 300w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-768x446.png 768w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image.png 1342w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now click Create<\/p>\n\n\n\n<p>Click on the Manage link on the far right of the row where you see your application created. You&#8217;ll be presented with a similar image as above but this will contain your Client ID as well. Copy this value. You are going to need this in two places. <\/p>\n\n\n\n<p>First in the file you have opened in the editor amend line 5 so it looks like this put your client ID in between the quotes<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var clientId = 'Client_ID_here';<\/code><\/pre>\n\n\n\n<p>Second go to the first page you opened and paste your Client ID where prompted you&#8217;ll also need to supply the scopes, you just need this one: channel_read. Your form should look like this:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-1.png\" alt=\"\" class=\"wp-image-318\" width=\"778\" height=\"605\" srcset=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-1.png 778w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-1-300x233.png 300w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-1-768x597.png 768w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/figure>\n\n\n\n<p>Click the Connect button and then the Authorize button when prompted with this dialog:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"1024\" src=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-2-607x1024.png\" alt=\"\" class=\"wp-image-319\" srcset=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-2-607x1024.png 607w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-2-178x300.png 178w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-2.png 632w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/figure>\n\n\n\n<p>You&#8217;ll then see a page like this:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"183\" src=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-3.png\" alt=\"\" class=\"wp-image-320\" srcset=\"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-3.png 784w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-3-300x70.png 300w, https:\/\/www.unshapedadrian.co.uk\/blog\/wp-content\/uploads\/2022\/03\/image-3-768x179.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/figure>\n\n\n\n<p>Whatever you do <strong>never<\/strong> share this value with anyone, it allows access to your channel (although at least this token will only have minimal read permissions).<\/p>\n\n\n\n<p>Copy &#8220;Your OAuth token&#8221; and edit line 6 in the file you have open in the editor<\/p>\n\n\n\n<p>You should end up with something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Update these values to reflect your own channel name and other variables&lt;\/p>\nvar channel = 'channelname';\nvar clientId = 'client_id';\nvar oAuthToken = 'oauth_token';<\/code><\/pre>\n\n\n\n<p>Save the file you have open in the Editor.<\/p>\n\n\n\n<p>Now add the tool to your streaming tool as documented in the <a href=\"http:\/\/www.unshapedadrian.co.uk\/blog\/code\/how-to-add-the-current-games-box-art-to-your-scene-when-streaming-to-twitch\/\">original article<\/a> and you should get things working.<\/p>\n\n\n\n<p>OAuth tokens do not last forever so if the tool stops working you will need to refresh your Token using the steps above.<\/p>\n\n\n\n<p>I appreciate that this seems super complicated for something that&#8217;s so simple. Twitch has changed it&#8217;s API authentication for very good reasons, mainly protecting your personal data, and this is the reason I stopped working on these tools and providing updates because there is no safe way to store your confidential information in this simple scenario. However I got a few requests and this is the simplest solution (yes I know) that I could come up with. I did search around the internet for other solutions to offer people but the main places I know, Stream Labs and Stream Elements don&#8217;t have a box art widget or app. If you know of a better solution please feel free to comment or message me on Twitter<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A long time back I wrote two tools which use standalone HTML and javascript to get data from Twitch, one was Box Art which I documented here: Box Art Blog Post These tools have stopped working recently because Twitch changed a lot of requirements specifically to do with Authentication when accessing the APIs. I didn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,20,21],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-code","category-streaming","category-tech"],"_links":{"self":[{"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":5,"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions\/324"}],"wp:attachment":[{"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unshapedadrian.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}