This flow applies to apps you created in My apps. Integrations set up before My apps may still use the password grant described in Authentication.
Apps sign people in with the OAuth 2.0 authorization code flow with PKCE (S256) against the Ed Controls identity service. It is standard OpenID Connect, so any certified OAuth or OIDC library works. The password grant and the client credentials grant are not available to these apps. Prefer configuring your library from the discovery URL over hardcoding the endpoints.

1. Send the user to sign in

Generate a random code_verifier, derive code_challenge = BASE64URL(SHA256(code_verifier)), and redirect the browser to:
The redirect_uri must match one of your app’s redirect URIs exactly. The user signs in with their Ed Controls account and is shown a consent screen listing your app’s name and the scopes it asks for.

2. Exchange the code for tokens

Ed Controls redirects back to your redirect_uri with code and state. Check that state is the one you sent, then:
The answer holds an access_token (a JWT with an expires_in), a refresh_token and, with the openid scope, an id_token. Send the access token as Authorization: Bearer <token> to the API. It carries the API’s audience (edcontrols-api) and the signed-in user’s identity.

3. Refresh

Access tokens are short-lived. Get a new one with the refresh token before or when a call returns 401:
Store the newest refresh token from each answer.

Scopes

A scope bounds what your app asks for. What it may actually do is still decided by the signed-in user’s roles, exactly as in the Ed Controls app.

Long-running integrations

For a background job (an ERP sync, a nightly export) that runs without a person present:
  1. Create a dedicated Ed Controls user for it, a service account, and give it only the project roles it needs.
  2. Sign in through your app once as that user, with offline_access in the scope, and approve the consent screen.
  3. Store the refresh token in your secret manager and use it to get access tokens from then on.
If the refresh token stops working (the user’s password changed, the consent was revoked, or the app’s secret was rotated and the refresh was sent with the old one), repeat step 2.

Errors