Welcome to the Panopto Community

Please note: All new registrants to the Panopto Community Forum must be approved by a forum moderator or admin. As such, if you navigate to a feature that is members-only, you may receive an error page if your registration has not yet been approved. We apologize for any inconvenience and are approving new members as quickly as possible.

Issues using `users/search` endpoint

Hi,

I'm having issues using the /api/v1/users/search endpoint. When I construct a command such as the following, I don't get an appropriate response. Am I constructing the search term incorrectly?

def get_panopto_users():
  url = f"https://{panopto_domain}/Panopto/api/v1/users/search"
  headers = {
    "Authorization": f"Bearer {panopto_oauth_token}"
  }
  params = {
    "searchQuery": "stephenwb"
  }

{'Results': []}
Tagged:

Answers

  • For what it's worth, I'm ultimately trying to enumerate all users within Panopto, so if I can use wildcards here, that would be great!

  • edited September 9

    Hello Stephen,

    The search parameters seem to be correct. Could you verify the Python package you are using and the verify the contents of the request that is being sent? If you send a larger code snippet, I could help you out. Here is a sample code that I tried and it worked fine for me. The API won't return an empty list unless there are no users with that username.

    image.png


    Hope this helps.

    Regards,
    Aish.

  • edited September 16

    Aish,

    Here you go:

    import requests
    
    token_url = f"https://({DOMAIN})/Panopto/oauth2/connect/token"
    data = {
        "client_id": {CLIENT_ID},
        "client_secret": {CLIENT_SECRET},
        "grant_type": "client_credentials",
        "scope": "api",
    }
    
    response = requests.post(url=token_url, data=data).json()
    panopto_oauth_token = response["access_token"]
    
    url = f"https://{DOMAIN}/Panopto/api/v1/users/search"
    headers = {
        "Authorization": f"Bearer {panopto_oauth_token}",
        "Content-Type": "application/json",
    }
    params = {
        "searchQuery": "stephenwb"
    }
    
    response = requests.get(url=url, params=params, headers=headers).json()
    
    print(response)
    

    The response being:

    {'Results': []}
    

    FWIW, we do have users in our system (redacted for reasons):

    SCR-20250910-iqun.png

    … and fwiw, my user account does exist, and i've tried permutations of stephenwb, [email protected], SSO\[email protected] and SSO\\[email protected].

    As mentioned earlier, I'm looking to grab a list of all of our users (and groups, but I'll get to that later), not just individual users (maybe by using a wildcard like *). So if there's a better way to do this than using a search endpoint, please let me know.

    I'm using Python 3.11.13.

  • Hi, any news on this please?

  • Are you using the correct client type in the API client registration? As far as I can tell, the client_credentials grant type is used with a 'server application' and it will not allow the use of endpoints that require user authentication:

    1.3.c. A Server Application client can only create tokens with no user associated. The access tokens created for a Server Application client would not be authorized for any API calls that require a user or user permission. These can only be used for service endpoints that do not require a specific user or user permission.

    Perhaps try User-based Server Application instead, with password as Grant_type

  • Creating a new API client using User-based Server Application, updating the Client ID and Secret accordingly in the above script, and changing the grant_type to password results in {'error': 'invalid_grant'} when attempting to get an access token.

    Where does it mention that the users endpoint requires user authentication?

  • I just assumed you'd need to be authenticated as a user to be able to search for users. I just tried setting up a new 'server application' API client and when getting a token using client_credentials grant I get the same result as you when searching for users:

    {   

    "Results": []

    }

    If trying either JavaScript Web Application (Implicit Grant) or User-Based Server Application (password grant) it works fine for me.

    Someone from Panopto should be able to give some directions here..

  • edited September 17

    That could be another issue. Please make sure that the API Client you have created in Panopto is a User Based Server Application. When configuring a new token for your application, make sure the Grant type is Password Credentials - this should allow you to use your username + password and Client ID + Client Secret to generate a new token that should be used in your header as a Bearer token. As per your python code, you are using client credentials. This should be changed to password credentials. Following is the exact code that I used to generate the auth token and get results from the search API. Hope that you can follow this to achieve the results that you want. Please fill in the client_id, client_secret, username and password in the following code and it should give you the expected results.

    image.png


    Regards,
    Aish

Sign In or Register to comment.