cancel
Showing results for 
Search instead for 
Did you mean: 
msanders
Community Contributor

Add a second login via import or using the API?

We have standardized the Canvas usernames/passwords assigned to students but they are unfortunately too complex for our younger students. I would like to assign these students a simple username/password combination to use while in K-3. It would be great if I could add the simpler logins to the user's accounts instead of overwriting the standard combination.  I know I can manually add a second login but is there a way to add a second login via import or API? I didn't see anything in the documentation but thought I'd ask.

4 Replies
garth
Community Champion

I think this can be done with the Logins api:  Logins - Canvas LMS REST API Documentation - Create a user login

To quote the API doc:  "Create a new login for an existing user in the given account"

This sound like what you want to do.

I'm not able to test and confirm this now, but will try to confirm tomorrow.

It seems you are trying to create user names that are simpler than email addresses.

Have you thought about how you are going to generate unique user names that are easier for the younger kids?

I think that will be the hard part.

garth
Community Champion

I sneeked away for a few minutes and tested the API call: Logins - Canvas LMS REST API Documentation - Create a user login

It seems to do exactly what you asked for.

Here is an example of how the syntax for testing with Postman:

https://mycanvas.test.instructure.com/api/v1/accounts/1/logins?user[id]=1234&login[unique_id]=mySimp...

Where user[id] is the numeric value matching the Canvas user id associated with the account that has already been created

And login[unique_id] is the new simple user id that you want to give to the kids

And login[password] is the password that you will give to the kids

Using this API call users will have two user id's they can use to login with.

I hope this helps.

msanders
Community Contributor

This is great - thank you! 

Every student in our school has a unique 4 digit number that they use to buy lunch, check out library books, and log into our other educational software programs. The younger students are very familiar with this number and that's the "username" we plan to use.  We do run the risk of them fat-fingering the ID and logging in as someone else, but with K-3 students it's not a big concern. I did test that Canvas would accept the username/combo we are planning to use.

bduggan96
Community Member

Hello!

I was looking to do a similar task of adding a second login via API, as we are overhauling our adfs SSO mapping to better match our SIS.  With that said, I have linked my GitHub (Link 1) below to be able to copy my Python script.  I have also attached the documentation upon which I used to build this code (this article being one of them).  Essentially, you only need to create an API bearer token within Canvas (Link 2), copy that key into the two API fields within the Python Code which is commented, add in your school's URL link which is also commented, and tweak the code so that it is adding the desired secondary login to your Canvas account.

 

Currently the code runs and creates a secondary login with the user's email, whose initial login username is a SIS provided username.  You are able to change that field to whatever you would like as the POST request, but do ensure that they are unique usernames (ID number, email address, etc.)  It will also create a .txt document to show a log of students who were changed and/or ignored.

 

If you are wanting to update everyone's login credential, I would utilize the SIS Import feature (Link 3).  You possibly could change the Python script to have a PUT request instead, that also should work, but I would certainly recommend testing both of these scripts on your test site before moving on to your production site.

 

Depending on how many users you have, this code could take anywhere from 20min to 2hrs to run as it goes through every user and their login credentials.

Hope this is helpful!

Link 1: https://github.com/switchroute/Python/blob/master/canvasloginpostapicall.py

 

Link 2: https://community.canvaslms.com/t5/Admin-Guide/How-do-I-manage-API-access-tokens-as-an-admin/ta-p/89

 

Link 3: https://canvas.instructure.com/doc/api/file.sis_csv.html