YouTube.js icon indicating copy to clipboard operation
YouTube.js copied to clipboard

2.3.2 Upload failed with status 401

Open flolep2607 opened this issue 2 years ago • 22 comments

Steps to reproduce

It's not a brand account

Failure Logs

Hello!
On your phone or computer, go to https://www.google.com/device and enter the code ZRV-QTD-DGP
Successfully signed in!
/home/flo/mass_prox/tst/node_modules/youtubei.js/dist/src/utils/HTTPClient.js:112
            throw new Utils_1.InnertubeError(`Request to ${response.url} failed with status ${response.status}`, yield response.text());
                  ^

InnertubeError: Request to https://upload.youtube.com//upload/youtubei?key=xxxxxxxxxxxxxxxxxxxx&prettyPrint=false&alt=json failed with status 401
    at HTTPClient.<anonymous> (/home/flo/mass_prox/tst/node_modules/youtubei.js/dist/src/utils/HTTPClient.js:112:19)
    at Generator.next (<anonymous>)
    at fulfilled (/home/flo/mass_prox/tst/node_modules/youtubei.js/dist/src/utils/HTTPClient.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  info: '{"status":"STATUS_REJECTED","rejectionReason":"REJECTED_NOT_AUTHENTICATED"}',
  date: 2022-11-05T16:02:11.243Z,
  version: '2.3.2'
}

Node.js v17.9.1

Expected behavior

upload the video

Current behavior

response code 401 unable to upload

Version

Default

Anything else?

It's not a brand account

Checklist

  • [X] I am running the latest version.
  • [X] I checked the documentation and found no answer.
  • [X] I have searched the existing issues and made sure this is not a duplicate.
  • [X] I have provided sufficient information.

flolep2607 avatar Nov 05 '22 16:11 flolep2607

Hmm weird, are you able to update video metadata? I've never seen this happening with normal accounts.

LuanRT avatar Nov 06 '22 05:11 LuanRT

i'm also getting this, any update?

bezaleel22 avatar Dec 16 '22 21:12 bezaleel22

i'm also getting this, any update?

@onos9 Are you able to use other methods that require authentication (update video thumbnail, metadata, get account info and etc)? I tried reproducing this but unfortunately couldn't, so it's a bit complicated to debug. You can also try cookie auth to see if it throws the same error.

Edit: And if possible, please try uploading with different accounts.

LuanRT avatar Dec 16 '22 21:12 LuanRT

Thanks for the feedback, I have not really tried other methods, I'm actually new to this repository, what do I need to do get credentials for login. I used Google Oauth2 and also realised there is no option for youtube-private-video and gdata in the consent scope. Thanks for this great project, I would really love to use this in my project, thanks.

bezaleel22 avatar Dec 17 '22 12:12 bezaleel22

I have successfully uploaded a video, thank you very much for your response, is there any callback for upload progress?

bezaleel22 avatar Dec 17 '22 13:12 bezaleel22

@LuanRT is there any documentation on how to login via cookie specifically what cookie name copy from the cookie store

bezaleel22 avatar Dec 24 '22 15:12 bezaleel22

@onos9 Were you able to successfully upload a video using this library? I can't seem to find a way to upload. New to this library.

yashb042 avatar Jan 17 '23 13:01 yashb042

@onos9 Were you able to successfully upload a video using this library? I can't seem to find a way to upload. New to this library.

@yashb042 Can you try cookie authentication? Just copy the whole cookie from a YouTube's API req and pass it to the cookieoption in the library.

I'm still trying to figure out why this happens to some accounts, but I reckon it's most likely because the /upload/youtubei endpoint is rejecting the OAuth bearer token.

Edit: If you're just looking for examples, there's one here.

LuanRT avatar Jan 17 '23 20:01 LuanRT

@yashb042 yes I was able to upload successful, it actually worked for my account

bezaleel22 avatar Jan 17 '23 20:01 bezaleel22

@LuanRT just curious, is there a way to live stream from this library if so, can you show an example.

A live streaming feature will be awesome for this great library. Thanks for the work it really help me alot.

bezaleel22 avatar Jan 17 '23 20:01 bezaleel22

@onos9

Not possible yet.

The way YouTube handles live streams seems a bit complicated, but I do want to try to implement it at some point.

Thanks!

LuanRT avatar Jan 18 '23 21:01 LuanRT

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 20 '23 02:03 github-actions[bot]

Hello,

I am also getting this problem. I think 401 problem comes with newly created Channel on Youtube.

So, Step to reproduce the error would be:

  1. Create New YouTube channel and don't verify the phone number.
  2. try to upload video to new channel with Youtube.js and it will start to give 401 error.

Successfully signed in! { 'Content-Type': 'application/x-www-form-urlencoded', 'x-goog-upload-command': 'start', 'x-goog-upload-protocol': 'resumable' } URL { href: 'https://upload.youtube.com//upload/youtubei?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false&alt=json', origin: 'https://upload.youtube.com', protocol: 'https:', username: '', password: '', host: 'upload.youtube.com', hostname: 'upload.youtube.com', port: '', pathname: '//upload/youtubei', search: '?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false&alt=json', searchParams: URLSearchParams { 'key' => 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8', 'prettyPrint' => 'false', 'alt' => 'json' }, hash: '' } InnertubeError: Request to https://upload.youtube.com//upload/youtubei?prettyPrint=false&alt=json failed with status 401 at HTTPClient.<anonymous> (C:\Users\Gunpa\Downloads\YouTube.js-main (1)\YouTube.js-main\examples\channel\node_modules\youtubei.js\src\utils\HTTPClient.ts:145:13) at Generator.next (<anonymous>) at fulfilled (C:\Users\Gunpa\Downloads\YouTube.js-main (1)\YouTube.js-main\examples\channel\node_modules\tslib\tslib.js:164:62) at processTicksAndRejections (node:internal/process/task_queues:95:5) { info: '{"status":"STATUS_REJECTED","rejectionReason":"REJECTED_NOT_AUTHENTICATED"}', date: 2023-04-19T18:05:51.530Z, version: '4.3.0' }

I am looking for solution to upload videos on newly created channel.

gunpal5 avatar Apr 19 '23 18:04 gunpal5

@gunpal5 Thank you! That seems to be the case indeed. I'm not very hopeful but I'll see if there's any workaround.

LuanRT avatar Apr 20 '23 04:04 LuanRT

@LuanRT

I have C# codes which uploads to YouTube just fine on newly created channel. but those codes require YouTube cookies to work, these cookies are the same when you login to Youtube on a web browser like Google Chrome.

I am not sure if you have any cookies based authentication implemented in Youtube.js. If you have it I will share the codes.

The codes I have basically mimic the http calls, which are sent to YouTube server when you try to upload videos through a web browser.

Anyway, I appreciate your efforts in developing a library like YouTube.js

gunpal5 avatar Apr 20 '23 09:04 gunpal5

@gunpal5 Yes it does support cookies. Feel free to share anything you think might help solving this, it'd be greatly appreciated!

LuanRT avatar Apr 28 '23 23:04 LuanRT

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 28 '23 02:06 github-actions[bot]

I seem to be running into this issue as well, and I see no option in Youtube to verify my phone number. The account is about 3 weeks old.

@LuanRT How do I use cookies with Youtubejs?

chen-rn avatar Jul 26 '23 07:07 chen-rn

I seem to be running into this issue as well, and I see no option in Youtube to verify my phone number. The account is about 3 weeks old.

@LuanRT How do I use cookies with Youtubejs?

Check if you can upload from the YouTube app itself first. It should prompt you to do whatever verification is needed.

As for cookies, try the cookie prop when creating a new session.

LuanRT avatar Jul 26 '23 19:07 LuanRT

I can upload from the Youtube Studio web app. I do not have an android device on me to test using the Youtube app.

I'll try the cookies method!

chen-rn avatar Jul 26 '23 21:07 chen-rn

I have 4 channels under 1 acount. The first channel works perfctly, but the rest 3 encountered 401 when uploading videos.

cantfindone avatar Jan 12 '24 07:01 cantfindone

@cantfindone Yeah, this is still a problem unfortunately. I'll have to investigate how the mobile app handles this to implement it properly in YouTube.js.

LuanRT avatar Jan 12 '24 17:01 LuanRT