RequestAuthorizationError: '401: Authorization Failed' | jpseabrook | 2017-06-12 08:50 | |||||||||||||||||||||||||||||||||
Status: Closed | |||||||||||||||||||||||||||||||||||
Hi, I'm trying to make use of the python api but I'm having some troubles. My server is on a local network but has a public domain and SSL cert attached. I'm using get_user_by_email() to test the connection and the script is throwing a 'RequestAuthorizationError: '401: Authorization Failed'. I've setup a user labkey on the server to run Labkey Server via tomcat8 with startup.sh/shutdown.sh. The 'Runtime Information' lists the 'User Home Dir' and 'Working Dir' as '/home/labkey'. Any help would be greatly appreciated. ****** /home/labkey/.netrc (chmod 400) ****** machine [PUBLIC DOMAIN ADDRESS] login [LOGIN EMAIL ADDRESS] password [PASSWORD] ****** script running in a jupyter notebook ****** from labkey.utils import create_server_context from labkey.query import select_rows from labkey.security import create_user, get_user_by_email labkey_server = '[PUBLIC DOMAIN ADDRESS WITH PORT]' project_name = 'test' # Project folder name contextPath = 'labkey' schema = 'core' table = 'Users' server_context = create_server_context(labkey_server, project_name, contextPath, use_ssl=True) print("Created a server context") print(get_user_by_email(server_context, '[LOGIN EMAIL ADDRESS]')) ****** exact error output ****** Created a server context --------------------------------------------------------------------------- RequestAuthorizationError Traceback (most recent call last) <ipython-input-25-9bfd09f77045> in <module>() 12 print("Created a server context") 13 ---> 14 print(get_user_by_email(server_context, '[LOGIN EMAIL ADDRESS]')) /opt/miniconda3/lib/python3.6/site-packages/labkey/security.py in get_user_by_email(server_context, email) 130 url = server_context.build_url(user_controller, 'getUsers.api') 131 payload = dict(includeDeactivatedAccounts=True) --> 132 result = server_context.make_request(url, payload) 133 134 if result is None or result['users'] is None: /opt/miniconda3/lib/python3.6/site-packages/labkey/utils.py in make_request(self, url, payload, headers, timeout, method) 149 else: 150 raw_response = self._session.post(url, data=payload, headers=headers, timeout=timeout) --> 151 return handle_response(raw_response) 152 except SSLError as e: 153 raise ServerContextError(e) /opt/miniconda3/lib/python3.6/site-packages/labkey/utils.py in handle_response(response) 73 74 elif sc == 401: ---> 75 raise RequestAuthorizationError(response) 76 elif sc == 404: 77 try: RequestAuthorizationError: '401: Authorization Failed' |
|||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||