Thanks for the reply. I’ve included the code below, minus some fluff like access token caching and my actual client ID/secret.
var urlPrefix = 'https://api.twitch.tv/kraken/',
request = require( 'request' ),
kraken = request.defaults( {
baseUrl: urlPrefix,
headers: {
'Accept': 'application/vnd.twitchtv.v5+json',
'Client-ID': CLIENT_ID
}
} ),
twitch = {};
twitch._authenticate = function ( scope, force = false ) {
return new Promise( function ( resolve, reject ) {
kraken.post( {
uri: '/oauth2/token',
json: true,
body: {
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'grant_type': 'client_credentials',
'scope': scope.join( ' ' )
},
}, function ( err, res, body ) {
if ( err ) {
reject( err );
} else {
resolve( body.access_token );
}
} );
} );
}
twitch._getSubscriberList = function ( accessToken ) {
kraken.get( {
uri: '/channels/' + CHANNEL_ID + '/subscriptions',
headers: {
'Authorization': 'OAuth ' + accessToken
}
}, function ( error, res, body ) {
console.log( error ); // null
console.log( res ); // response object which shows correct request headers
// and invalid token error
} );
}
twitch._authenticate( ['channel_subscriptions'] ).then( token => {
twitch._getSubscriberList( token );
} );
You mentioned something about making sure the token is for the correct channel. The Client ID & Secret I used to request the token are the ones Twitch provided when I registered the application, which was done on the same account for which I’m requesting the subscription list. So hopefully that should mean that the token corresponds to that account? Very new to v5 here though.
I also tested virtually the same code as twitch._getSubscriptionList with the Follower list endpoint since it doesn’t require authorization. That one worked perfectly fine, so I’m fairly confident in the code I’m using for the request.
Thanks in advance for any light you can help shed on the matter!