Skip to content

Commit

Permalink
Add "Missing SESSION_TOKEN" exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyzesc committed Jun 10, 2022
1 parent f19a623 commit adf738a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/youtube-studio-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,21 @@ async function getEndScreen(videoId) {


async function upload(options) {
//
// @tyzesc
//
// Fix GitHub issue #21
// https://github.com/adasq/youtube-studio/issues/21
//
// Missing SESSION_TOKEN will make YouTube return 401 Unauthorized Error,
// and uploadFile pass null value to node-fetch and will cause error.
//
if (typeof sessionToken !== 'string' || sessionToken.length === 0) {
throw {
text: 'Missing SESSION_TOKEN on init will cause Unauthorized Request. Please check your SESSION_TOKEN is set correctly in init function.'
}
}

return uploadFile(options, headers, config, sessionToken)
}

Expand Down Expand Up @@ -619,4 +634,4 @@ module.exports = {
setInfoCards,
getVideoClaims,
upload
}
}

0 comments on commit adf738a

Please sign in to comment.