Using the New API and getting Invalid OAuth token

I’m trying to understand the New API and trying to execute an example code

C:\Users\RAIN>curl -X GET https://api.twitch.tv/helix/search/channels?query=l1zzka -H “Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx” -H "Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko

but i getting an error like this:

{“error”:“Unauthorized”,“status”:401,“message”:“Invalid OAuth token”}

I can’t understand, what is the OAuth token and how to get it.

And also…

Blockquote
To make API calls, you need a client ID. To receive one, log into the Twitch developer console, select the Apps tab, and click Register Your Application. Enter an app name and your OAuth redirect URI (where your users are redirected after being authorized), and select an app category. Click Create, and the app is created and listed on the dashboard as one of your registered apps. Click Manage to see the client ID.

I just need to get the user ID, channel’s videos list etc.
Why i must redirect my users to somewhere and for what exactly it needed? What it means?

Get a Client-ID by registering your application: https://dev.twitch.tv/console/apps

Use this Client id in conjunction with the bearer token you get with a process listed here: https://dev.twitch.tv/docs/authentication#types-of-tokens

The new API system requires a little bit more than the previous, but once you get a program authenticating itself once, you should be fine from there.

OK, but i still can’t understand for what exactly we need the Redirect URI?

Blockquote
2 If the user authorizes your application, the user is redirected to your redirect URL:

why?

The original token is one you can get yourself using a tool like This One Here. You use this token to get an “access token” but since it’s all public data you can just re-use the original token for your account to lookup info such as the channels endpoint without user-specific authentication.

I’ve included a Code Sample Below from one of my bots.

Twitch.prototype.authenticate = function (callback) {
    const opts = {
        url: 'https://id.twitch.tv/oauth2/validate',
        headers: {
            'Authorization': `Bearer ${<Original_OAuth_Token>}`,
            'Client-ID': `${<Client ID>}` //Client-ID from your dev portal
        }
    };
    request(opts, function (error, response, body) {
        if (!error && response.statusCode == 200) {
            const output = JSON.parse(body);
            return callback(null, output);
        } else (
            console.log(`ERROR WITH AUTHENTICATE! ${response}`)
        )
    });
}

Twitch.prototype.channels = function (userID, callback) {
    const that = this;
    this.authenticate(function (err, output) {
        const opts = {
            url: `https://api.twitch.tv/helix/channels?broadcaster_id=${userID}`,
            headers: {
                'Authorization': `Bearer ${<Original_OAuth_Token>}`,
                'Client-ID': `${output.client_id}` // New Client-ID
            }
        };
        request(opts, function (error, response, body) {
            if (!error && response.statusCode == 200) {
                const info = JSON.parse(body);
                return callback(null, info.data[0]);
            } else (
                console.log(response)
            )
        });
    });
    }

I understand. I confuse with examples.
Actually, i need this:

curl -X POST “https://id.twitch.tv/oauth2/token?client_id=MY_ID&client_secret=MY_SECRET&grant_type=client_credentials
curl -X GET https://api.twitch.tv/helix/search/channels?query=l1zzka -H “Authorization: Bearer TOKEN” -H “Client-Id: MY_ID”