Click here to go to GitHub


Insert OneClick.py into your project.


First, import OneClick.

import OneClick

Next, you need to create a OneClick and set the info in OneClick with setConfig(client_key and client_secret).

oc = OneClick()

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
  • oneroster - Access to oneroster info and classes
  • full - Access to all public apis

Scope will be defaulted to profile if not included.

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.

# Prints the url for the 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 

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(bearer, endpoint, extractNode), 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 getInfo(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 included in the method call.
It will return the info as a JSON response in a string.

# Prints the JSON response from the request to the endpoint


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

# Prints user info as JSON


This method will get the district associated with the user

# Prints the district as JSON


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

# Prints info on the user's profiles as JSON


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

# Prints children info


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


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

# Print the oneroster info about the User


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

# Print the oneroster info about user's classes

getUserOneRosterClassTeachers(bearer, classSourcedId)

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

# Print the oneroster info on the teacher of the class
print(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.

# Print the oneroster info the students of the class
print(oc.getUserOneRosterClassStudents("cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "sourcedId"))