Canvas API 401 Error Using a new Access Token
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since creating a new Access Token for the integration, I'm able to upload sis csv import files with the API. However, I am not able to use any of the other API calls (i.e. create logins, list canvas terms, etc...). Seeing how I am an Admin, I am not sure why this is happening. The error is "Invalid access token" when attempting to use calls other than sis csv import calls.
Previous Access Token worked fine. It expired so I created the new one.
Here is an example of using curl with a list terms call and a file upload call:
W20190643:Canvas crierk$ curl -H "Authorization: Bearer <Access Token>" 'https://wou.instructure.com/api/v1/accounts/1/terms'
{"errors":[{"message":"Invalid access token."}]}W20190643:Canvas crierk$
W20190643:Canvas crierk$ curl -F attachment=@/Users/crierk/Canvas/Terms_20230106-150242.csv -H "Authorization: Bearer <Access Token>" 'https://wou.instructure.com/api/v1/accounts/self/sis_imports.json?import_type=instructure_csv'
{"id":327587,"created_at":"2023-01-07T07:50:54Z","started_at":null,"ended_at":null,"updated_at":"2023-01-07T07:50:55Z","progress":0,"workflow_state":"created","data":{"import_type":"instructure_csv"},"batch_mode":null,"batch_mode_term_id":null,"multi_term_batch_mode":null,"override_sis_stickiness":null,"add_sis_stickiness":null,"update_sis_id_if_login_claimed":false,"clear_sis_stickiness":null,"diffing_data_set_identifier":null,"diffing_remaster":null,"diffed_against_import_id":null,"diffing_drop_status":null,"skip_deletes":false,"change_threshold":null,"diff_row_count_threshold":null,"user":{"id":532,"name":"Kolis Crier","created_at":"2020-06-09T10:13:43-07:00","sortable_name":"Crier, Kolis","short_name":"Kolis Crier","sis_user_id":"V00326970","integration_id"H "Authorization: Bearer <Access Token>" 'https://wou.instructure.com/api/v1/accounts/self/terms?search_term=202202'
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @chriscas
Thanks for chiming in.
I spent some time with Canvas support and didn't appreciate the deflecting tactics. For instance, telling me that the "purpose" field of the access token is what determines what the token can be used for.
I wound up creating yet another token. That token works consistently.
I suspect that the token I create may have been corrupted behind the scenes since it only "Kind of" worked. Or... Canvas support fixed the issues without saying an issue existed and thus the subsequent token worked. Who knows.
I am good to go now.
Thanks again.
-Kolis