Creating a user via the api with a destination parameter to automatically login user

DavidGeismar2
Community Novice

I am creating a user through the canvas API and once created I need to redirect my user to the canvas instance and ideally have the user automatically signed in.

Looking at the docs : https://canvas.instructure.com/doc/api/users.html#method.users.create,

I can see that I have to set :

user[skip_registration] as true

- pseudonym[password] as a random password

- pseudonym[send_confirmation] as true

1) When I do this, the user indeed receives a confirmation informing him that his account was created. However the email does not tell the user what is his password, which is unfortunate. Is there a way to let canvas set a random password for the user and then send that password to the user ? Or if I have to set it myself do I have to do all the work and send an email myself to inform the user of its password ?

 

Now, the second part of my question. I would like to be able to redirect the newly created user to the canvas instance and I would like the user to be automatically logged in.
Unfortunately I dont think Canvas implements SSO JWT in the same way as an LMS like 360Learning does --> https://support.360learning.com/hc/en-us/articles/209016626-Technical-guide-SSO-JWT

Did I miss something or does canvas actually has some sort of SSO JWT ?

However I noticed in the api doc for "create user" a "destination" parameter. It says :

"If you’re setting the password for the newly created user, you can provide this param with a valid URL pointing into this Canvas installation, and the response will include a destination field that’s a URL that you can redirect a browser to and have the newly created user automatically logged in. The URL is only valid for a short time, and must match the domain this request is directed to, and be for a well-formed path that Canvas can recognize."

Indeed, when I do as such, I get back in the response something like :
{"id"=>663,
"name"=>"JDJ DJDJD",
"created_at"=>"2024-08-20T01:32:46+02:00",
"sortable_name"=>"DJDJD, JDJ",
"short_name"=>"JDJ DJDJD",
"sis_user_id"=>nil,
"integration_id"=>nil,
"sis_import_id"=>nil,
"login_id"=>"dageismar+raarkarkkr@gmail.com",
"locale"=>"en",
"uuid"=>"maX5Qf4Rz67jq1e8DTEeivMZcoFyqoAOhpVtyGOT",
"destination"=>
"https://somedomain.instructure.com/?session_token=somerandomtoken"}

However, when I try to use that destination url, I am always redirected to the login screen and asked for my credentials :(.
Am I missing something here ?

Labels (1)
0 Likes