Giter Club home page Giter Club logo

schoology-api's Introduction

schoology-api

Java implementation for the Schoology 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) implementation.

Setup:

Run the following commands to install the package in your local Maven repository:

$ 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:

<dependency>
    <groupId>net.rvanasa</groupId>
    <artifactId>schoology-impl</artifactId>
    <version>1.0.0</version>
</dependency>

Usage:

You can generate a user API key & secret by going to https://[DISTRICT_PREFIX].schoology.com/api

2-Legged Auth:

SchoologyRequestHandler schoology = new SchoologyRequestHandler(DISTRICT_PREFIX, API_KEY, API_SECRET);

3-Legged Auth:

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:

// [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 user

schoology.put("users/[UID]", "{\"name_first_preferred\": \"NewName\"}"); // set preferred first name

Using premade methods & objects:

// [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 for taking this project to the next level. Contributions and feature requests are always welcome!

schoology-api's People

Contributors

dependabot[bot] avatar electro2560 avatar rvanasa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

schoology-api's Issues

Example post

Hello

By any chance do you have an example of a post request? I have the correct endpoint, but I can't figure out how to correctly form the body so I'm getting a 415 response.
Here's what I've tried that I think should be working, but it must be formed wrong
image

Thanks!

Do I Need Keys Per District?

How does this work when deploying an app? Would we need to register with Schoology? Would we request keys for each district site and then use those keys according to the referrer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.