Unauthorized, token missing or invalid

I authorized my account for the channel_editor scope and it returned me back to redirect_uri with ?code= in the url.

Is that code the OAuth?
Cause I get Unauthorized, token invalid or missing with the following:

if(index($chat_msg, 'Incorrect usage') eq -1) {
        	$chat_msg = qx(curl -H 'Accept: application/vnd.twitchtv.v3' -H 'Authorization: OAuth $ch->{_oauth}' -d 'channel[status]=$chat_msg' -X PUT https://api.twitch.tv/kraken/channels/$ch->{_user});
	return sprintf( "%s", $chat_msg );

{“error”:“Unauthorized”,“status”:401,“message”:“Token invalid or missing required scope”}


if I go to https://api.twitch.tv/kraken/user/?oauth_token= it says Unauthorized but the token is valid, see below code:

 $loginURL = $twitch->authLoginURL('user_read user_blocks_edit channel_editor user_blocks_read channel_commercial channel_subscriptions user_subscriptions channel_check_subscription');
            return View::Make('twitch/authorize', array('loginURL' => $loginURL));

It redirects me, I autorize and go back to the website with the oauth token as GET parameter ?code=

An auth code is NOT an oauth token, it is something you exchange for an oauth token. See https://github.com/justintv/Twitch-API/blob/master/authentication.md#auth-code for more information.