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.
- Sign up for a Scalekit account.
- Get your
env_url
,client_id
andclient_secret
from the Scalekit dashboard.
- Java 1.8 or later
Add this dependency to your project's build file:
implementation "com.scalekit:scalekit-sdk-java:2.0.2"
Add this dependency to your project's POM:
<dependency>
<groupId>com.scalekit</groupId>
<artifactId>scalekit-sdk-java</artifactId>
<version>2.0.2</version>
</dependency>
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");
}
}
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.
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();
}
}
Fully functional sample applications written using Spring Boot and Scalekit SDK. Feel free to clone the repo and run them locally.
Refer to our API reference docs for detailed information about all our API endpoints and their usage.
- Quickstart Guide to implement Single Sign-on in your application: SSO Quickstart Guide
- Understand Single Sign-on basics: SSO Basics
This project is licensed under the MIT license.