A 401 error code means that you don't have authorization to that resource. It is possible that the request is working in the browser because you are logged in to Youtube with your account.
I think that you need to generate some OAuth 2.0 authorization credentials to use that API.
https://developers.google.com/youtube/v3/live/registering_an_application
Can't really help you more, but I would look into that.
I've tried putting it on my website and it's still the same
I'll give it a try with OAuth 2.0, thanks