RequestAuthorizationError: '401: Authorization Failed'

LabKey Support Forum (Inactive)
RequestAuthorizationError: '401: Authorization Failed' Jon (LabKey DevOps)  2017-06-12 13:32
Status: Closed
 
Hello,

Does the user in question have the ability to view the core.Users table from the UI?

I ran a similar query and had no issues doing this against labkey.org's own servers:
==============================
import labkey
from labkey.utils import create_server_context
from labkey.query import select_rows

labkey_server = 'www.labkey.org'
project_name = 'home'
schema = 'core'
table = 'Users'

server_context = create_server_context(labkey_server, project_name, use_ssl=True)

result = select_rows(server_context, schema, table)
if result is not None:
    print(result['rows'][0])
    print("select_rows: Number of rows returned: " + str(result['rowCount']))
else:
    print('select_rows: Failed to load results from ' + schema + '.' + table)
==============================

I did notice you didn't have the "import labkey" option at the top of your python code. Did you make sure to include that too before the:

from labkey.utils import create_server_context
from labkey.query import select_rows
from labkey.security import create_user, get_user_by_email

So it would look like:

import labkey
from labkey.utils import create_server_context
from labkey.query import select_rows
from labkey.security import create_user, get_user_by_email

Regards,

Jon