Invalid Response 401


I am new to Xibo and I am running into issues while trying to configure a replacement script. Following the guide, when running the first part of the

import os
from xml.dom import minidom
import XiboAPI

api = XiboAPI.XiboAPI()

When running the following message is displayed.

Traceback (most recent call last):
File “”, line 12, in
api = XiboAPI.XiboAPI()
File “c:\Scripts\”, line 69, in init
user_token, user_secret = self.setupUserToken(url,consumer_key,consumer_secr
File “c:\Scripts\”, line 99, in setupUserToken
raise Exception(“Invalid response %s.” % resp[‘status’])
Exception: Invalid response 401.

I know the 401 message is related to authentication, but I do not understand why this happens. Does anyone have a clue?
Thanks in advance.


If you are using API for the first time, ie the consumer_key consumer_secret and oAuth are not configured yet.
It’s quite normal to receive unauthorised(401) error.

Perhaps try to proceed to the next steps in the guide and make sure that you configure everything correctly.

Thank Peter,

The default.cfg has been updated with the correct path and keys that were generated by adding a application
I am at this point and I do not get the expected output

•Save defaults.cfg and close it
•Save your ReplaceVideo,py script
•Now lets run what we have:

And I expected the below output, but instead I received the 401 message.

alex@alex-laptop:~/scratch/xibo-release/ReplaceVideo$ python
Request Token:
- oauth_token = 7dda5851bf99e09bdad1b27aebaa6fd005303dc3e
- oauth_token_secret = a289a41cab324475c849283d553b113b

Go to the following link in your browser:

Have you authorized me? (y/n)

Any other thoughts?

It sounds to me like the keys you’ve entered are wrong. Try deleting the application from inside the CMS and adding it again, then update the keys in defaults.cfg and remove any keys that have been added to site.cfg

Thanks Alex / Peter.
I ran into other issues as well, so I decided to start from scratch. If I run into the same issues again, I will come back on this.
Is there anything I should take in consideration, that I maybe missed, regarding the scripts to run them on a Windows 2008 R2 server with IIS 7?

It’s not a platform that we explicitly support or test on, but it should be OK as far as I know.

I have created a new server and installed everything from scratch. Everything is working as expected, except the Replace script. I have followed evrything by the letter in the manual, but I still get the same message. I can assure that the keys are correctly added to the default.cfg.

Has anyone successfully implemented a ReplaceVideo script or a similar script on a Windows 2008 R2 and IIS? Any suggestions that could solve my problem, as I really need this script working.

Thanks in advance.

I have set the logging to Audit and when I run the script the following is added in the logfile “OAuth Webservice call” and the following is added to the Application log.

OAuthException2: SQL Error in OAuthStoreMySQL: Array ( [0] => HY000 [1] => 1364 [2] => Field ‘ost_referrer_host’ doesn’t have a default value ) INSERT INTO oauth_server_token SET ost_osr_id_ref = 1, ost_usa_id_ref = 1, ost_token = ‘ef23ea052f5d8c84fffda697d2abce6d0568e26fa’, ost_token_secret = ‘53635952c09d2b9eca5ee84856106440’, ost_token_type = ‘request’, ost_token_ttl = DATE_ADD(NOW(), INTERVAL 3600 SECOND), ost_callback_url = ‘oob’ ON DUPLICATE KEY UPDATE ost_osr_id_ref = VALUES(ost_osr_id_ref), ost_usa_id_ref = VALUES(ost_usa_id_ref), ost_token = VALUES(ost_token), ost_token_secret = VALUES(ost_token_secret), ost_token_type = VALUES(ost_token_type), ost_token_ttl = VALUES(ost_token_ttl), ost_callback_url = VALUES(ost_callback_url), ost_timestamp = NOW() At file C:\inetpub\wwwroot\xibo\3rdparty\oauth-php\library\store\OAuthStoreSQL.php, line 1241

Accept-Encoding: gzip, deflate Content-Length: 0 Host: User-Agent: Python-httplib2/0.9.2 (gzip)

Anyone any idea on how to solve this issue?
Thanks in advance

A quick Google for that brings up this:

Looks like IIS isn’t setting an http referrer and so when we try and enter a NULL referrer in the database we can’t.

You could run the SQL suggested against the oauth_server_token table in the database but you may then have problems with future database upgrades. That said it’s simple enough to revert so as long as you remember you’ve done that if you do have problems down the line then we’ll know where to start looking.

Perfect, that solved the issue.
Thank you for your assistance.

1 Like