[ARCHIVED] Download Completed Report File via API Developer Key
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is an API to start and run reports and check the status of a running report and when status=complete it will even give the download url of the report file: https://canvas.instructure.com/doc/api/account_reports.html
When attempting to download the report file using the API developer key authentication, it does not authenticate.
Now I'm stuck, how do I authenticate to programmatically download the report file? I've tried getting a refresh_token to use via google sso with no success. Is there some known way to authenticate programmatically for the report download URLs?
BTW, the download URLs simply end up redirecting through to insgate cloud files, why not provide the direct link in the API instead of a link that requires user authentication?
Why not provide a download link that allows developer key authentication before the redirect?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately as I mentioned in my original post I could not use any of the canvas API authentication mechanisms to download the report file. Still seems silly to allow API access to start the report, check the status is completed, get the file_url for download, but not be able to use API authentication to allow the download.
What I have done to work around the deficiency is automate the user authentication login form with specific accounts user/pass.
- GET /login/canvas
- Parse the response html and grab the value of authenticity_token.
- POST authenticity_token, along with pseudonym_session[unique_id] and pseudonym_session[password] for a specially created user account.
- Parse the response header with the cookie that contains the canvas_session value.
- Get the file_url value from a completed report object using typical API calls.
- GET <file_url> with the canvas_session as a cookie header.
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.