Skip to content

scalekit-inc/scalekit-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Official Java SDK

Scalekit is an Enterprise Authentication Platform purpose built for B2B applications. This Java SDK helps implement Enterprise Capabilities like Single Sign-on via SAML or OIDC in your Java applications within a few hours.


Pre-requisites

  1. Sign up for a Scalekit account.
  2. Get your env_url, client_id and client_secret from the Scalekit dashboard.

Installation

Requirements

  • Java 1.8 or later

Gradle users

Add this dependency to your project's build file:

implementation "com.scalekit:scalekit-sdk-java:2.0.2"

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>com.scalekit</groupId>
    <artifactId>scalekit-sdk-java</artifactId>
    <version>2.0.2</version>
</dependency>

Usage

Initialize the Scalekit client using the appropriate credentials. Refer code sample below.

import com.scalekit.ScalekitClient;
import com.scalekit.exceptions.APIException;
import com.scalekit.grpc.scalekit.v1.organizations.CreateOrganization;
import com.scalekit.grpc.scalekit.v1.organizations.Organization;
import com.scalekit.grpc.scalekit.v1.organizations.UpdateOrganization;

public class ScalekitExample {

    public static void main(String[] args) {
        client = new ScalekitClient("env_url",
                "client_id",
                "client_secret");
        }
}
Minimum Requirements

The Scalekit Java SDK is designed to operate with the following environment:

Component Version
Java 8+

Tip: While our Java SDK requires Java 8 as the baseline, we suggest upgrading to more recent LTS versions such as Java 11 or Java 17. These updates deliver performance improvements and enhanced security.

Examples - SSO with Spring Boot

Below is a simple code sample that showcases how to implement Single Sign-on using Scalekit SDK

@RestController
public class AuthController {
    ScalekitClient scalekitClient = client = new ScalekitClient("env_url", "client_id", "client_secret");

    @Value("${auth.redirect.url}")
    private String redirectUrl;

    @PostMapping( path = "auth/login")
    public RedirectView loginHandler() {
        AuthorizationUrlOptions options = new AuthorizationUrlOptions();
        String url = scalekitClient.authentication().
                getAuthorizationUrl(redirectUrl, options)
                .toString();
        return new RedirectView(url);
    }

    @GetMapping("auth/callback")
    public String callbackHandler(@RequestParam String code, HttpServletResponse response){
        
        AuthenticationResponse authResponse = scalekitClient.authentication()
                .authenticateWithCode(code, redirectUrl, new AuthenticationOptions());
        Cookie cookie = new Cookie("access_token", authResponse.getAccessToken());
        response.addCookie(cookie);
        return authResponse.getIdToken();
    }
}

Example Apps

Fully functional sample applications written using Spring Boot and Scalekit SDK. Feel free to clone the repo and run them locally.

API Reference

Refer to our API reference docs for detailed information about all our API endpoints and their usage.

More Information

License

This project is licensed under the MIT license.

About

A Java SDK that empowers your app to implement Single Sign-On (SSO) for enterprise solutions.

Topics

Resources

License

Stars

Watchers

Forks

Languages