Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central Version

Stupidly Simple OAuth2

This is my personal OAuth2 library for use in locally installed java applications. It is designed to be as simple as possible. The only dependency is on FasterXML/jackson for JSON parsing.

Why this exists

I wanted to enable an application I developed to use OAuth2 and I couldn't find a slim and easy to use library. That's why I created my own.

Usage

  1. Include the dependency in your pom (or the equivalent for your build tool):
<dependency>
    <groupId>net.nikomitk</groupId>
    <artifactId>ssoauth2-client</artifactId>
    <version>0.1</version>
</dependency>
  1. Create an instance of a flow and initialize it:
import net.nikomitk.ssoauth2.OAuth2Flow;
import net.nikomitk.ssoauth2.flows.OAuth2UserPasswordFlow;

OAuth2Flow flow = new OAuth2UserPasswordFlow("sso.example.com/.well-known/openid-configuration", "client-id", "username", "password", "openid profile email");
flow.startFlow(); // Initialization
  1. Execute the needed steps as often as you need (you can store the flow instance in order to periodically refresh your token:
flow.requestAccessToken(); // Request the access token from the authorization server

flow.refreshAccessToken(); // Refresh the access token in a way suitable for your chosen flow

flow.getAccessToken(); // Getter for the access token stored in the flow

For simpler use, you can also chain these methods:

flow.requestAccessToken().refreshAccessToken().getAccessToken(); // Getter for the access token stored in the flow

Available flows

Currently, the following flows are available:

I plan to add more in the future, but I currently don't have enough time. Contributions are welcome.

About

Read-only mirror of https://codeberg.org/nikomitk/StupidlySimpleOAuth2

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages