Set Server
NetKnowledgy Canvas API Examples
Please note that these are quick examples, no error handling
has been implemented.
This site demonstrates obtaining access to the Canvas API and
making some API calls.
Access to the Canvas REST API is facilitated via a bearer token.
This token can be obtained by one of two methods:
- manual (user-generated); or
- OAuth2.
Using both of these methods is demonstrated here.
Server
Your server must be accessable via https and have a valid
server certificate.
Enter the hostname of your Canvas server:
Token Type
You can generate a token manually, or use OAuth2.
Manual (User-Generated) Token
You can generate a token in Canvas.
Go to your
Account Settings
and scroll down to "Approved Integrations" and click "+ New Access Token".
OAuth2 Authentication - Developer Key
Given a Developer ID and Key, allows a user to authorise an application.
The application then displays some user information and their courses.
To use this application, you need to have a developer key with a Redirect URI
of
https://canexa.netkno.nz/oauth/token.
If the key is using scopes, also enter the scope(s) you would like this token to have.
For example: url:GET|/api/v1/users/:user_id/profile
Enter the key's ID and Key:
OAuth2 Authentication - User Authorisation
Now that the ID and Key are set, you can get a Token, which will allow the application
to make Canvas API calls. This is the point at which the user has to authrorise the
application in Canvas.
If you have entered an invalid ID, when you click "Get Token" Canvas will return the following to your browser
instead of re-directing to this application with an error message:
while(1);{"error":"invalid_client","error_description":"unknown client"}
If you have entered an invalid Key, Canvas will generate a code, but it will give an error when this
code is used to get the access token. The error will be handled by this application.