Skip to content

Commit

Permalink
Merge pull request #33 from tyzesc/tyzesc-patch-missing-session-token
Browse files Browse the repository at this point in the history
Add "Missing SESSION_TOKEN" exception.
  • Loading branch information
adasq committed Jun 10, 2022
2 parents f19a623 + adf738a commit 9d245b0
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 9d245b0

Please sign in to comment.