Register for InstructureCon25 • Passes include access to all sessions, the expo hall, entertainment and networking events, meals, and extraterrestrial encounters.
Found this content helpful? Log in or sign up to leave a like!
Hello Canvas Community,
We are working on an integration using the Canvas LMS API, and are attempting to generate an access token for a student using the endpoint:
POST /api/v1/users/:user_id/tokens
https://www.canvas.instructure.com/doc/api/access_tokens.html
We are using an admin-level access token
However, we are experiencing issues:
The token is not returned, or is returned in a "pending"
state with no "token"
value.
There appears to be no way to activate the pending token programmatically or via impersonation.
We could not find clear documentation or UI references on how a specific user (e.g., the student) can manually activate a pending token created by an admin
Solved! Go to Solution.
Hi @brandon42,
May I ask why you're attempting to create individual user access tokens? I think that is going to be a very frowned upon practice overall.
The more common route would be to use a Developer Key / oAuth2 flow to be able to do API calls on behalf of users.
-Chris
Hi @brandon42,
May I ask why you're attempting to create individual user access tokens? I think that is going to be a very frowned upon practice overall.
The more common route would be to use a Developer Key / oAuth2 flow to be able to do API calls on behalf of users.
-Chris
Hi @brandon42,
When you use that API endpoint to create a token on a user's behalf, that user must activate it themselves; I don't have a screenshot handy but when they look at their tokens it will be in the "Pending" state and they will have an "Activate" button they can click. If you hit that POST endpoint for your own user account you should be able to see it. An admin masquerading as the user can explicitly not activate the token and there is no programmatic way to do so, which is a reasonable security consideration on Instructure's part to guarantee that tokens really truly belong to the user they're associated with. If you are trying to make API calls on behalf of other users, the oAuth 2 flow that Chris references is the appropriate way to do so. Lastly, I'm assuming you deleted that token or never activated it, but be careful with your screenshots -- putting that full text token out there could give someone access to your Canvas instance!
To interact with Panda Bot in the Instructure Community, you need to sign up or log in:
Sign In