myschool.lymyschoolHelp Center
Help Center

How to create an access token and make an API call to myschool

Register a client app, generate an OAuth access token with the client ID and secret, and call the myschool API.

2 min read Last updated: 30 September 2026

To make an API call to myschool, first generate an access token, and then use it to call the API.

1. Register the client app in myschool

  1. Go to Settings → Manage Clients.
  2. Click New to add a new client.
  3. Enter the Name and Redirect URI, and select Verified.
  4. Save the client. A Client ID and Client Secret are generated. You will use them to generate the access token.

2. Generate the access token

Pass the client ID, client secret, username and password to the token endpoint. Sample code:

function get_token(username, password) {
  var xhr = new XMLHttpRequest();
  xhr.open("POST", "https://yourschool.myschool.ly/oauth/token", true);
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhr.onreadystatechange = function (e) {
    if (xhr.readyState == 4 && xhr.status == 200) {
      console.log(e.target.responseText);
    }
  };
  var token = xhr.send(
    "client_id=YOUR_CLIENT_ID" +
    "&client_secret=YOUR_CLIENT_SECRET" +
    "&grant_type=password" +
    "&username=" + username +
    "&password=" + password +
    "&redirect_uri=http://localhost:3001/authorize"
  );
  return token;
}

Call this function with the username and password as parameters.

3. Call the API

Call the API with the token and the path of the resource you want to read or write. Sample function:

function callApi(token, path) {
  var httpRequest = new XMLHttpRequest();
  httpRequest.onreadystatechange = function (evt) {
    console.log("xhr.readyState :: " + httpRequest.readyState);
    console.log("xhr.status :: " + httpRequest.status);
    if (httpRequest.readyState == 4 && httpRequest.status == 200) {
      console.log(evt.target.responseText);
    }
  };
  httpRequest.open("GET", "https://yourschool.myschool.ly/api/" + path);
  httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  httpRequest.setRequestHeader("Authorization", 'Token token="' + token + '"');
  httpRequest.send();
}

The response contains the requested data.

Note: Replace yourschool.myschool.ly with the address of your school’s myschool site, and http://localhost:3001/authorize with the redirect URI of your client app. The client ID, secret and URIs shown here are placeholders only.

See also: What can I do with the myschool API? in the API section.

Still need help?

Our support team is available Sunday to Thursday, 9 AM – 3 PM.