Authentication in the context of an Ed-Fi ODS / API is essentially the process of credential exchange and verification to establish that a client is allowed to access the platform. Authentication in an Ed-Fi ODS / API is handled using two-legged OAuth 2.0 Client Credentials Grant Flow.
Before accessing the resources in an Ed-Fi ODS / API platform, client applications need to obtain an access token from the API platform host. This access token is validated on every call made to the API as a representation of the client's application key and secret. This document briefly outlines the steps involved.
The steps below walk you through the process that a client uses to supply credentials and receive a token. These steps are generally the same whether you use a command-line tool like cURL or whether you bake the steps into your client application. Most programming languages, including C# and Java, provide objects that handle these steps for you, but it's worth understanding what the steps are.
Throughout this section, we will be using a command-line tool called cURL. It is used to transfer information between systems using a variety of protocols (including HTTP and HTTPS). For our purposes, it serves as a concise shorthand for the HTTP information included to make the various calls to the Ed-Fi ODS / API. Compiled executables for a variety of platforms can be downloaded from the cURL website.
Step 1. Obtain an Access Token
POST the to the
/oauth/token with an Authorization header of "Basic <64 base encoded client key : client secret>". The
Grant_type will be set to
client_credentials. This follows the process described by the Basic Authentication Scheme. For Example, if the client id or key is RvcohKz9zHI4 and the client secret is E1iEFusaNf81xzCxwHfbolkC, the value for the Authorization header would be "Basic Base64EncodedKey:Secret"
*Note: curl --user option should base-64 encode the key and secret into the Authorization header.
The above should return an access token.
The snippet below shows an example response with an access token. You will get a different access token.
In the OAuth2 Client Credentials Grant Flow, the host issues an access token and the amount of time in seconds until the token expires. The token will expire at the end of that allotted time and a new token will have to be obtained.
Step 2. Use the Access Token
On subsequent API requests, include the access token in an HTTP Authorization header as "Bearer XYZ" where "XYZ" is the access token.
The following example uses the Authorization token to retrieve the schools in the sandbox ODS / API hosted by the Ed-Fi Alliance. Replace the
Bearer value with the access token returned in the previous step.
As another example, the following call retrieves the discipline incidents recorded in the sandbox ODS / API. Don't forget to replace the
You can explore the whole API surface in this manner, but there are easier ways. See the section called Using the Online Documentation for more information.
The next section, Authorization, has more details about using the access token.