LeRurik:
If I use the GrantType::AUTHORIZATION_CODE to get the access token at login, I then can’t actually log in the user. I also can’t get their display name/avatar for the user area because for that I would need their username or ID in the first place, which there doesn’t seem to be an endpoint for getting the user details for the current oauthed user?
You call Get users without an ID or Login just the Access token and it will return the User for that token
Or you can call the validate endpoint which will validate the token and return the user_id and login for the token. (Easy way to see what kind of token you have as well)
Example: Twitch Implicit Auth Example (when Github pages deploys in a moment)
if (document.location.hash && document.location.hash != '') {
var parsedHash = new URLSearchParams(window.location.hash.slice(1));
if (parsedHash.get('access_token')) {
var access_token = parsedHash.get('access_token');
document.getElementById('access_token').textContent = `Your Access Token extracted from the #url is ${access_token}`;
document.getElementById('user_data').textContent = 'Loading';
// call API
fetch(
'https://api.twitch.tv/helix/users',
{
"headers": {
"Client-ID": client_id,
"Authorization": `Bearer ${access_token}`
}
}
)
.then(resp => resp.json())
.then(resp => {