⚠️

Exciting News!

Our transition to a new website is complete. Click here to seamlessly access the latest version of this article.

Kindly update any bookmarked URLs accordingly. The Development Center will no longer be accessible after April 1, 2024. Thank you for your attention to this matter.

📘

GitHub and DLL Download Links

GitHub
DLL Download

Setup

Insert OneClick.cs into your project.

Or

Create a reference to the DLL in your project. To do this in Visual Studio 2017, right click Dependencies -> Add References -> Browse -> Select DLL -> Add.

Usage

First import OneClick if you're using a DLL.

using ClassLink_OneClick.OneClick;

Next, you need to create a new instance of OneClick with the client_key and client_secret.

OneClick oc = new OneClick("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

Generate Bearer Token

getCodeUrl(scope, redirectUri)

Following that, you will need to generate the url for you to sign in and retrieve your code, which will be used to get the access token. This is done with the method getCodeUrl(scope, redirectUri).

The scope can be:

  • profile - Access to user identiy and user specific information
  • full - Access to all public apis

Scope will be defaulted to profile not included in method call.

The redirectUri is the url that you will be redirected to upon login. It defaults to https://localhost:8080/code.

You can use curl or get the code from the url bar after signing in.

OneClick oc = new OneClick("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
// Prints the url for the code
Console.WriteLine(oc.getCodeUrl("full"));

getToken(code)

After getting the code from the url, you need to generate the bearer token that will be used for all the requests. This will be generated using the getToken(code) method.

// Uses the code received after signing in and returns the bearer token 
Console.WriteLine(oc.getToken("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

Accessing the Endpoints

Now that you have your bearer token, you can access the endpoints. This can be done through a number of methods. The first method, getInfo, allows the user to specify what endpoint they want to hit and what field to return. The rest of the methods will make requests to specific endpoints for specific information.

getInfo(bearer, endpoint, extractNode)

The main method used to make a request to an endpoint is get_info(bearer, endpoint, extractNode). It takes in the bearer token, the url of the endpoint (excluding the hostname), and an optional extractNode, which will return this specific field if is not passed as an empty string.
It will return the info as a JSON response in a string.

// Prints the JSON response from the request to the endpoint
Console.WriteLine(oc.getInfo("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "/path/info", ""));

getUserInfo(bearer)

This method will take in the bearer token and return a JSON containing all of the available user info

// Prints user info as JSON
Console.WriteLine(oc.getUserInfo("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

getUserDistrict(bearer)

This method will get the district associated with the user

// Prints the district as JSON
Console.WriteLine(oc.getUserDistrict("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

getUserProfiles(bearer)

This method will get info on the user's profiles.

// Prints info on the user's profiles as JSON
Console.WriteLine(oc.getUserProfiles("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

getUserChildren(bearer)

If the user is a parent registered for ClassLink, this will return a list of linked student accounts (their children)

// Prints children info
Console.WriteLine(oc.getUserChildren("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

getUserGroups(bearer)

Get a list of all groups that the user is a part of

// Prints a list of all groups that the user is a part of
Console.WriteLine(oc.getUserGroups("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

getUserOneRosterInfo(bearer)

Get all the OneRoster info about the user
Note: Only available for districts with OneRoster enabled.

// Print the oneroster info about the User
Console.WriteLine(oc.getUserOneRosterInfo("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

getUserOneRosterClasses(bearer)

Get all the OneRoster classes the user is enrolled in.
Note: Only available for districts with OneRoster enabled.
Info

// Print the oneroster info about user's classes
Console.WriteLine(oc.getUserOneRosterClasses("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

getUserOneRosterClassTeachers(bearer, classSourcedId)

Get info on the teacher of the class represented by the unique sourcedId.
Note: Only available for districts with OneRoster enabled.
Info

// Print the oneroster info on the teacher of the class
Console.WriteLine(oc.getUserOneRosterClassTeachers("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "sourcedId"));

getUserOneRosterClassStudents(bearer, classSourcedId)

Get info on the students of the class represented by the unique sourcedId.
Note: Only available for districts with OneRoster enabled.
Info

// Print the oneroster info the students of the class
Console.WriteLine(getUserOneRosterClassStudents("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "sourcedId"));