Search code examples
pythonyoutubeyoutube-apiyoutube-livestreaming-apiyoutube-data-api

youtube live streaming api inserting messages


I keep getting a error everytime i try to use the youtube live streaming api for sending messages in python

  list_chatmessages_inset = youtube.liveChatMessages().insert(
     part = "snippet",
     body = dict (
        snippet = dict(
           liveChatId = livechatId,
           type = "textMessageEvent",
           textMessageDetails = dict(
               messageText = "hello world"
           )
         )
      )
   )  

  print(list_chatmessages_inset.execute())

I get this error

An HTTP error 403 occurred:
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}

as a response back. I'm guessing this has something to do with my oauth but im unsure as to what to do to solve this the same oauth key works for my other method of trying to recieve messages. maybe that doesnt require authentication though? im not sure. But i got it to work in the live streaming api trying the api page.


Solution

  • Well, if you check the details about the 403 error Insufficient Permission, it means that the user is not authorized to do this command.

    I also found here that the details explaining why the user cannot stream live video may be available in the user's channel settings at https://www.youtube.com/features. So you may also check that site. (This site is not accessible for me)

    Note that maybe this issue is not all about the LiveChatMessages: insert, because if you check the error content for this method, you will not see any Insufficient Permission error with this. So I suggest you to debug more code and check for the other possible caused of this issue.

    These are the links that I think can help you.