canvasapi icon indicating copy to clipboard operation
canvasapi copied to clipboard

Just started throwing InvalidAccessToken exception

Open ron-sass opened this issue 1 year ago • 10 comments

My Python scripts that are based on canvasapi have stopped working in the last 10 days. (Definitely worked on 12/19/2022, was not working on 12/27/2022 and hasn't worked since.)

Just in case something changed locally, I uninstalled canvasapi-2.2.0 and installed canvasapi-3.0.0 ... removed some cruft from Python 3.9 and generally scoured my laptop for any other left over stuff.

Since the canvasapi package code had not changed, my best guess is that something canvasapi depends on changed but before I start sifting through the code, I thought I would ask if others have experienced the same problem.

Minimum (non)working example:

#!/usr/bin/python3
from canvasapi import Canvas
URL = 'https://uncc.instructure.com/'
KEY = '999999999999999999999999999999999999999999999999999999999999999999999'
canvas = Canvas(URL,KEY)
course = canvas.get_course(182727)

Results in an exception:

canvasapi.exceptions.InvalidAccessToken: [{'message': 'user authorization required'}]

However, I've checked and double checked access key ... it is the same one that has been working for 2+ years and it has not expired. Furthermore, I issued the same request from the command line:

curl https://uncc.instructure.com/api/v1/courses/182727 -X GET -H 'Authorization: Bearer 999999999999999999999999999999999999999999999999999999999999999999999'

and I get a reasonable JSON response:

{"id":182727,"name":"Logic System Design","account_id":108,"uuid":"7DbizAXeda7de7vOWXO8k1B9nfLKkSsDbmUoGoFO","start_at":null,"grading_standard_id":null,"is_public":false,"created_at":"2022-04-04T10:45:13Z","course_code":"202280-ECGR-2181-001:ECGR-2181-002-XLSEO202280_Combined","default_view":"wiki",...}

I'm hoping I am not doing something embarrassingly stupid ... but I'm stumped. Plus I'm traveling so I can't test on a clean system right now.

Ron

Additional info:

rick (master *)❱ pip show canvasapi Name: canvasapi Version: 3.0.0 Summary: API wrapper for the Canvas LMS Home-page: https://github.com/ucfopen/canvasapi Author: University of Central Florida - Center for Distributed Learning Author-email: [email protected] License: MIT License Location: /home/rsass/.local/lib/python3.10/site-packages Requires: arrow, pytz, requests Required-by:

rick (master *)❱ python3 --version Python 3.10.6

ron-sass avatar Dec 28 '22 20:12 ron-sass