https://github.com/rvanasa/schoology-api
Java API implementation for Schoology (https://schoology.com)
https://github.com/rvanasa/schoology-api
java-api lms oauth schoology schoology-api
Last synced: about 2 months ago
JSON representation
Java API implementation for Schoology (https://schoology.com)
- Host: GitHub
- URL: https://github.com/rvanasa/schoology-api
- Owner: rvanasa
- License: mit
- Created: 2016-05-02T19:00:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-11-15T04:25:05.000Z (over 1 year ago)
- Last Synced: 2025-03-26T00:11:08.259Z (3 months ago)
- Topics: java-api, lms, oauth, schoology, schoology-api
- Language: Java
- Homepage:
- Size: 202 KB
- Stars: 25
- Watchers: 10
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# schoology-api
Java implementation for the [Schoology API](https://developers.schoology.com/api).Behold, a straightforward two- and three-legged authentication wrapper for the Schoology REST API.
Make sure to use the `schoology-impl` module for the actual OAuth ([Scribe](https://github.com/scribejava/scribejava)) implementation.
## Setup:
Run the following commands to install the package in your local Maven repository:
```sh
$ git clone https://github.com/rvanasa/schoology-api
$ cd schoology-api/schoology-impl
$ mvn clean install
```Then, paste the following snippet into your project's POM.xml dependencies:
```xml
net.rvanasa
schoology-impl
1.0.0```
## Usage:
You can generate a user API key & secret by going to `https://[DISTRICT_PREFIX].schoology.com/api`
### 2-Legged Auth:
```java
SchoologyRequestHandler schoology = new SchoologyRequestHandler(DISTRICT_PREFIX, API_KEY, API_SECRET);
```
### 3-Legged Auth:
```java
SchoologyFlow flow = new SchoologyFlow(DISTRICT_PREFIX, API_KEY, API_SECRET, CALLBACK_URL);
SchoologyToken token = flow.createRequestToken();
String authUrl = token.getAuthorizationUrl();
// redirect client...
String verifier = "[Response from callback URL]";
SchoologyRequestHandler schoology = token.createRequestHandler(verifier);
```
### Sending a Request:
Requests can be send and parsed manually, or by using the premade methods provided with the SchoologyRequestHandler.
#### Manually:
```java// [UID] represents the target user ID
SchoologyResponseBody response = schoology.get("users/[UID]?extended=true").requireSuccess().getBody();System.out.println(response.getRawData()); // raw JSON string
SchoologyNode node = response.parse();
System.out.println(node.get("name_display").asString()); // get display name of userschoology.put("users/[UID]", "{\"name_first_preferred\": \"NewName\"}"); // set preferred first name
```
#### Using premade methods & objects:
```java// [UID] represents the target user ID
SchoologyUser user = schoology.getUser("[UID]");System.out.println(user.getNameDisplay()); // get display name of user
user.setNameFirstPreferred("NewName"); // set preferred first name
```
Big thanks to [@electro2560](https://github.com/electro2560) for taking this project to the next level. Contributions and feature requests are always welcome!