The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Twitch Auth Setup - Page 2

TODO: Pull subtitle into page object

This is the second page of a Twitch Auth setup process. If you got here without going through the first part you'll want to start there

OAuth Tokens

Assuming everything worked your tokens will show up here. Only a few characters are shown in case your on stream.




Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Twitch Auth Setup - Page 2 

-- note

This is the second page of a Twitch Auth
setup process. If you got here without
going through the first part you'll
want to <<link|start there|/twitch-auth/index.html>>

-- h2

OAuth Tokens

Assuming everything worked your tokens will 
show up here. Only a few characters are shown
in case your on stream.

-- html

<p>
<label for="access_token">Access Token:</label><br>
<input type="text" size="5" name="access_token" id="access_token">
</p>

<p>
<label for="refresh_token">Refresh Token:</label><br>
<input type="text" size="5" name="refresh_token" id="refresh_token">
</p>

<p>
<label for="expires_in">Expires In:</label><br>
<input type="text" size="5" name="expires_in" id="expires_in">
</p>


-- script

const s = {}

async function getCredentails () {
  if (s.code) {
    const formData = new FormData()
    formData.append("client_id", s.client_id);
    formData.append("client_secret", s.client_secret);
    formData.append("code", s.code);
    formData.append("grant_type", "authorization_code")
    formData.append("redirect_uri", s.redirect_uri)
    fetch(s.twitch_url, {
      method: "POST", body: formData
    })
      .then((response) => {
      return response.json()
    })
    .then((data) => {
      console.log(data)
      access_token.value = data.access_token
      refresh_token.value = data.refresh_token
      expires_in.value = data.expires_in
    })
  }
}

document.addEventListener("DOMContentLoaded", () => {
  s.address = window.location.href
  s.client_id = localStorage.getItem("twitch_client_id")
  s.client_secret = localStorage.getItem("twitch_client_secret")
  s.code = new URL(document.location).searchParams.get("code")
  s.redirect_uri = `${window.location.origin}/twitch-auth/page-2.html`
  s.twitch_url = "https://id.twitch.tv/oauth2/token"
  getCredentails()
})



-- categories
-- Twitch 

-- metadata
-- date: 2023-08-21 18:43:14
-- id: 2ujvibb8
-- site: aws
-- type: post
-- status: draft 
-- path: /twitch-auth/page-2.html