Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.2.0 Posts a comment with error 403 #633

Open
4 tasks done
meghe2000 opened this issue Apr 10, 2024 · 5 comments
Open
4 tasks done

9.2.0 Posts a comment with error 403 #633

meghe2000 opened this issue Apr 10, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@meghe2000
Copy link

Steps to reproduce

import { ClientType, Innertube } from 'youtubei.js';

async function start() {
const yt = await Innertube.create(
{
client_type: ClientType.WEB,
cookie: "my browser cookie..."
}
);
const vid = 'ZiplxPdOJd4';

const com = await yt.interact.comment(vid, 'GOOD');
console.log(com.data);

}

start();

Failure Logs

node_modules/youtubei.js/dist/src/utils/HTTPClient.js:101
            throw new InnertubeError(`Request to ${response.url} failed with status ${response.status}`, yield response.text());
                  ^

InnertubeError: Request to https://www.youtube.com/youtubei/v1/comment/create_comment?prettyPrint=false&alt=json failed with status 403
    at HTTPClient.<anonymous> (node_modules/youtubei.js/dist/src/utils/HTTPClient.js:101:19)
    at Generator.next (<anonymous>)
    at fulfilled (node_modules\tslib\tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  info: '{\n' +
    '  "error": {\n' +
    '    "code": 403,\n' +
    '    "message": "Comment failed to post.",\n' +
    '    "status": "PERMISSION_DENIED"\n' +
    '  }\n' +
    '}\n',
  date: 2024-04-10T12:53:30.800Z,
  version: '9.2.0'
}

Node.js v18.16.0

Expected behavior

Send a comment and get the result.

Current behavior

Not sending the comment while other functions like getHomeFeed works fine.

Version

Default

Anything else?

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@meghe2000 meghe2000 added the bug Something isn't working label Apr 10, 2024
@LuanRT
Copy link
Owner

LuanRT commented Apr 11, 2024

Works fine here, but I'm using OAuth. I do not recommend cookies because Google rotates them every 15 minutes or so.

Also, you do not need the client_type param. The WEB client is used by default in most cases.

Edit:
If switching authentication methods doesn't work, try the following:

const comments = await yt.getComments('VIDEO_ID');
console.log(await comments.createComment('test'));

@meghe2000
Copy link
Author

meghe2000 commented Apr 13, 2024

ClientType.ANDROID is faster than WEB.

import { ClientType, Innertube, UniversalCache } from 'youtubei.js';

async function start() {
    const vid = 'ZiplxPdOJd4';
    const yt = await Innertube.create(
        {
            cache: new UniversalCache(true),
            generate_session_locally: true,
            client_type: ClientType.ANDROID,
        }
    );

    yt.session.on('auth-pending', (data) => {
        console.log(`Go to ${data.verification_url} in your browser and enter code ${data.user_code} to authenticate.`);
    });

    await yt.session.signIn();
    await yt.session.oauth.cacheCredentials();
    console.log((await yt.getHomeFeed()).contents.contents.length);
}

When I use OAuth there is no problem with ClientType.WEB, but when I use ClientType.ANDROID I get this error.

node_modules/youtubei.js/dist/src/utils/HTTPClient.js:101
            throw new InnertubeError(`Request to ${response.url} failed with status ${response.status}`, yield response.text());
                  ^

InnertubeError: Request to https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json failed with status 404
    at HTTPClient.<anonymous> (node_modules/youtubei.js/dist/src/utils/HTTPClient.js:101:19)
    at Generator.next (<anonymous>)
    at fulfilled (node_modules\tslib\tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  info: '{\n' +
    '  "error": {\n' +
    '    "code": 404,\n' +
    '    "message": "Requested entity was not found.",\n' +
    '    "status": "NOT_FOUND"\n' +
    '  }\n' +
    '}\n',
  date: 2024-04-13T12:51:01.363Z,
  version: '9.2.0'
}

Node.js v18.16.0

@LuanRT
Copy link
Owner

LuanRT commented Apr 13, 2024

In your case, there's no difference. WEB is just as fast as ANDROID.

@TechBroCode
Copy link

ClientType.ANDROID is faster than WEB.

import { ClientType, Innertube, UniversalCache } from 'youtubei.js';

async function start() {
    const vid = 'ZiplxPdOJd4';
    const yt = await Innertube.create(
        {
            cache: new UniversalCache(true),
            generate_session_locally: true,
            client_type: ClientType.ANDROID,
        }
    );

    yt.session.on('auth-pending', (data) => {
        console.log(`Go to ${data.verification_url} in your browser and enter code ${data.user_code} to authenticate.`);
    });

    await yt.session.signIn();
    await yt.session.oauth.cacheCredentials();
    console.log((await yt.getHomeFeed()).contents.contents.length);
}

When I use OAuth there is no problem with ClientType.WEB, but when I use ClientType.ANDROID I get this error.

node_modules/youtubei.js/dist/src/utils/HTTPClient.js:101
            throw new InnertubeError(`Request to ${response.url} failed with status ${response.status}`, yield response.text());
                  ^

InnertubeError: Request to https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json failed with status 404
    at HTTPClient.<anonymous> (node_modules/youtubei.js/dist/src/utils/HTTPClient.js:101:19)
    at Generator.next (<anonymous>)
    at fulfilled (node_modules\tslib\tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  info: '{\n' +
    '  "error": {\n' +
    '    "code": 404,\n' +
    '    "message": "Requested entity was not found.",\n' +
    '    "status": "NOT_FOUND"\n' +
    '  }\n' +
    '}\n',
  date: 2024-04-13T12:51:01.363Z,
  version: '9.2.0'
}

Node.js v18.16.0

I just made use of WEB and it was successful.

@TechBroCode
Copy link

In your case, there's no difference. WEB is just as fast as ANDROID.

How do i clear the cached credentials? Take for instance if i'm switching accounts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants