Your Community is getting an upgrade!
Read about our partnership with Higher Logic and how we will build the next generation of the Instructure Community.
Found this content helpful? Log in or sign up to leave a like!
Hi all,
I'm part way through developing a script to scrape a course and find all instances where we use a specific API (Echo360 for those interested). For _reasons_ I need to then load that LTI so I can the final redirected URL where it lands. It's not sufficient to grab the URL from the Canvas page, I need it to fully load.
Is there any way to do that using the API to authenticate? Currently I just get a login page when I try to load the page via my Python script. Can I make a request to Canvas via the API that would return the fully loaded page, authenticated by my token (or as a specific user?)
Any help would be appreciated.
Cheers,
Jacob.
Solved! Go to Solution.
You can use this API to get a normal browser based session (with cookies) from an API call: https://canvas.instructure.com/doc/api/file.oauth_endpoints.html#get-login-session-token
So if you can then get your python client to keep the cookies you can then "launch" the LTI tool and grab the final URL that your python clients ends up at.
We've used that endpoint for doing browser test automation with things like https://playwright.dev/ reasonably successfully. Our test just has a API token which it then uses to get a full browser session.
You can use this API to get a normal browser based session (with cookies) from an API call: https://canvas.instructure.com/doc/api/file.oauth_endpoints.html#get-login-session-token
So if you can then get your python client to keep the cookies you can then "launch" the LTI tool and grab the final URL that your python clients ends up at.
We've used that endpoint for doing browser test automation with things like https://playwright.dev/ reasonably successfully. Our test just has a API token which it then uses to get a full browser session.
Brilliant, thank you. Glad that it works without having to do the whole OAuth dance too.
Ended up having to use Selenium to fully load the session link, as the LTI does a few too many redirects for Python to handle on its own, but its working now nicely. Thanks for the help!
Jacob.
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign InTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign In