A Custom Element that extends
<a>
to handle the Twitch OAuth login flow
This is for developers who are creating Twitch-related applications. If you want to login to Twitch, please head over to the actual site.
Note You will need to have an app in the Developer Console, and check the OAuth login flow
// html
<a is="twitch-login" scope="user:edit" client-id="[Client ID]">Login</a>
// js
import { getToken } from "https://cdn.skypack.dev/twitch-login/a"
const token = getToken()
Inner text defaults to "Login to Twitch"
// html
<script type="module" src="https://cdn.skypack.dev/twitch-login/a"></script>
<a id="login" is="twitch-login" scope="user:edit" client-id="[Client ID]"></a>
// js
const token = document.querySelector('#login').token
a[is="twitch-login"] {
padding: 10px;
display: block;
color: #f0f0ff;
text-align: center;
text-decoration: none;
background-color: #9146ff;
}
client-id
- (required) Client ID from the Developer Console.scope
- (required) Space-seperated list of scopesredirect
- (default:window.location.host
) URL to redirect the user to after the loginforce
- (default:false
) Re-prompt the user to loginanti-csrf
- (default:false
) Use a CSRF-token
Ensure that the Redirect URL is in the list for your application.