This is actually great. I'm happy to see code from someone familiar with the refresh process.
Can you explain a bit about the header you are sending along with your refresh token:
$header = array('Authorization: Basic ' . base64_encode(LMS_KEY . LMS_SECRET));
That's not in the Canvas API docs, and I've not done that before when posting to the /login/oauth2/token page. The docs just say to POST to the page, so that's all I've ever done. Most likely that has nothing to do with the reason why your new token is failing. Maybe the new one won't work unless the old one has expired? I hope a Canvas developer will chime in on this thread. I'd like to have a new process in place well before my old one stops working.
Previous OAuth systems I have worked with required the Client Id and Secret to be encode and sent as a header as part of getting the access token, this applies to both the initial token and getting a new token. If don't think Canvas requires this encoding but I continued it to add an extra layer or security to the request.
Thanks for the clarification. Sorry I am not more help, that was the only thing that I noticed skimming through your code. However, you do use a different approach than I do. I am hoping to rework one of my tools next week to use the refresh token. I will chime back into this thread if I experience the same issue or if I can figure it out.
I'm just beginning to work on the logic of what I'd like to do, so details are a bit sketchy. I need to add the same new page to the same module in about 75 different courses. The module is named/titled the same in each course, but of course has a different module id in each course. I have the course IDs in a CSV file and plan to loop through those course IDs and create a new page and then add that page to the module. However, I'm not sure how to identify the module ID as I go through each course. Is there a way to specify the module by name/title, or lookup the module ID based on the name/title?
This is a common scenario for us as we frequently have new or updated content that we need to add to many/all of our courses in Canvas. The body of the content is the same for every course and it's always going into the same module which exists in every course. Previously we've had to do this manually, one course at a time, which seems very inefficient.
If anyone has successfully done something similar, I'd love to see the code you used. I'm planning to use Python, but I'm open to other suggestions if someone already has this working.
The module listing API supports search, so that should help some. Probably
want to import only when the module search only turns up one result, and
then mop up the others manually.
Academic Technology Services
Project Blog <http://sites.udel.edu/bkinney/>
On Wed, Dec 2, 2015 at 11:05 AM, email@example.com <
I'm working on a project to scan quizzes for certain combinations of settings that are proving problematic, or that are using either Lockdown Browser or Proctorio.
I'd prefer to not have to load all courses to then load all /courses/quizzes to scan every quiz for it's create/edit date. What I need is a way to use the API to retrieve all quizzes that were created or edited in the last 24 hours. Is there a filter on /quizzes that would do this?
I personally don't know a way to do this using the API. You might want to look at Canvas Hosted Data for this problem. You can query for this using Canvas hosted data.
I did some digging and was unable to find a way to create this type of filter. firstname.lastname@example.org reference to hosted data is by far the easiest way to do this. If you don't have access to hosted data you can at least narrow the courses you are searching by retrieving all of the courses in an account filtered to the current term (Accounts - Canvas LMS REST API Documentation).
Tip: If you are working with the root account and/or the current term, you can use:
See Object IDs, SIS IDs, and special IDs - Canvas LMS REST API Documentation for some other great substitution options.