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.

trying to obtain Access token through OAuth2 using python, getting inconsistent result

it was working sometimes and stopped working altogether.

I used the API client creeated on panopto website using my admin account and try to get the access token so that I can continue my work on making a small program to obtain videos as backup for the teachers. unfortunately have been continuously trying but access token is none or empty all the time, and showing invalid_client as an error here is my implementation

Tagged:

Answers

  • Hello.

    Thank you for reaching out. If possible, could you share the token URL you are using?
    Also, the scope should be set to 'api'. If you could try with these params and let us know?

  • https://pntdev1.hku.hk/Panopto/oauth2/connect/token
    not sure if this is what you mean by the token url

  • DEFAULT_SCOPE = ('openid', 'api')

    this is my definition of DEFAULT_SCOPE on my end

  • Can you please help, thanks

  • Can you please help, thanks

    the access token issue is NOT RESOLVED.

  • Hi Sonic,

    Can you double check again if the API client is available in the Panopto UI, and verify your client ID and client secret?
    You you re-generate client secret if you need again and use that value.

    I hope this helps.

    Thanks,

    Adis

  • I can see my API client when I login admin account on panopto UI, do I need to regenerate the secret?

  • Hi Sonic,

    Yes, let's regenerate the secret and try to use the new secret for your API calls.

    If this fails, please let me know what is the error exception you get.

    Thanks,

    Adis

  • Get a new access token with username and password.
    https://pntdev1.hku.hk/Panopto/oauth2/connect/token
    ('openid', 'api')
    An error occurred while fetching the access token: (invalid_client)
    Response content: {}
    4735 attempt
    Authorization failed. Access token is None or empty.
    this is what I got when I try to obtain the access token, after regenerating the secret on the website

  • Hi Sonic,

    I don't have your full code to try to test it but can you base your implementation on our Python sample:

    https://github.com/Panopto/panopto-api-python-examples/blob/master/common/panopto_oauth2.py

    Let me know if you have any questions.

    Thanks,

    Adis

  • Sonic AuSonic Au Tyro
    edited March 4

    Hi Adis,
    I have a python program that is based on the repo,

    Can you see if anything went wrong there?

    Thanks,
    Sonic

  • Adis HrnjicaAdis Hrnjica Crackerjack

    Hi Sonic,

    If I execute everything from your code and it works.

    python login.py --server [Panopto server name] --client-id [Client ID] --client-secret [Client Secret] --username [User name] --password [User's password]
    

    You need to make sure any functions you call they get the token first.
    I have created this test API client just like this:

    1. Sign in to the Panopto web site
    2. Click the System icon at the left-bottom corner.
    3. Click API Clients
    4. Click New
    5. Enter an arbitrary Client Name
    6. Select User Based Server Application type.
    7. Enter https://localhost into CORS Origin URL.
    8. The rest can be blank. Click "Create API Client" button.
    9. Note the created Client ID and Client Secret.

    Let me know once you execute above command does it work.

  • Hi Adis,
    I tried this on a development environment and it can get the access token without issue, but when I try to do the same on production environment it fail to receive access token again…

    Sonic

  • Hi Aidis, I got
    Error fetching session 6C8D1FDA-BE68-4923-A217-077CD53EF062: 401 Client Error: Unauthorized for url: https://pntdev1.hku.hk/Panopto/api/v1/sessions/6C8D1FDA-BE68-4923-A217-077CD53EF062
    a 401 when attempting to get the downloadUrl from the response json

  • I am testing it on development env right now and I can get the access token, but for the /api/v1/sessions api I am getting 401s

  • according to the api it says

    The user is not authorized to perform the requested action

    but I am using admin account

  • Adis HrnjicaAdis Hrnjica Crackerjack

    Hi Sonic,

    Can you check API clients on local/dev vs production environment. If the same code works in dev and doesn't work on production then the only issue could be your user account and API client.

    Check both of those once again to confirm you have good user with admin permissions and good API client info.

    I hope this helps.

    Thanks,

    Adis

  • Hi Adis,

    I am using admin account on both environment and created the API client in the same way, but the id and secret is different, of course. yet it works on dev but not production
    this is the test env account


    and this is prod



    Thanks,
    Sonic

  • Adis HrnjicaAdis Hrnjica Crackerjack

    Hi Sonic,

    Can you send me a message with you site URL so i could create a API client and test? Thanks

    Adis

  • https://lecturecapture.hku.hk/

Sign In or Register to comment.