SDKs overview
Okta provides Software Development Kits (SDKs) and libraries designed to facilitate the integration of its identity and access management services into various application types. These tools aim to simplify the process of adding authentication, authorization, and user management features, abstracting underlying protocols like OAuth 2.0 and OpenID Connect (OIDC). Developers can use these SDKs to implement single sign-on (SSO), multi-factor authentication (MFA), user registration, and secure API access across web, mobile, and backend applications.
The SDKs are categorized by platform and programming language, offering idiomatic interfaces for common identity tasks. This approach allows developers to work within their preferred development environments while connecting to Okta's cloud-based identity services. The range of supported languages and frameworks reflects Okta's focus on broad compatibility for enterprise and customer-facing applications, as detailed in the Okta developer documentation.
Official SDKs by language
Okta maintains a suite of official SDKs for popular programming languages and frameworks. These SDKs are developed and supported by Okta, ensuring compatibility with the latest API versions and security standards. They typically cover core functionalities such as user authentication, token management, and interaction with the Okta management API.
The following table lists some of the primary official SDKs, their corresponding package names, common installation methods, and their general maturity status. Maturity often reflects the stability, feature completeness, and community adoption of the SDK.
| Language/Framework | Package/Module | Installation Command | Maturity |
|---|---|---|---|
| JavaScript (Browser/Node.js) | @okta/okta-auth-js |
npm install @okta/okta-auth-js or yarn add @okta/okta-auth-js |
Stable |
| Go | github.com/okta/okta-sdk-golang |
go get github.com/okta/okta-sdk-golang |
Stable |
| Python | okta-sdk-python |
pip install okta-sdk-python |
Stable |
| Java | okta-sdk-java (Maven/Gradle) |
Maven: <dependency><groupId>com.okta.sdk</groupId><artifactId>okta-sdk-api</artifactId><version>...</version></dependency> |
Stable |
| C# (.NET) | Okta.Sdk |
dotnet add package Okta.Sdk |
Stable |
| Ruby | okta-ruby |
gem install okta-ruby |
Stable |
| PHP | okta/okta-sdk-php |
composer require okta/okta-sdk-php |
Stable |
| React Native | okta-react-native |
npm install okta-react-native |
Stable |
| Angular | @okta/okta-angular |
npm install @okta/okta-angular |
Stable |
| Vue | @okta/okta-vue |
npm install @okta/okta-vue |
Stable |
| Swift (iOS/macOS) | OktaOidc (CocoaPods/SwiftPM) |
CocoaPods: pod 'OktaOidc' |
Stable |
| Kotlin (Android) | okta-oidc-android (Gradle) |
implementation 'com.okta.android:okta-oidc-android:...' |
Stable |
Installation
The installation process for Okta SDKs generally follows the standard package management practices for each respective language or framework. For JavaScript-based environments (Node.js, React, Angular, Vue, React Native), npm or yarn are the primary tools. Python SDKs are installed via pip. Java projects typically use Maven or Gradle for dependency management. Go modules are managed with go get, and Ruby gems with gem install. C# applications utilize NuGet packages installed via dotnet add package. PHP projects integrate SDKs through Composer.
For mobile development, Swift projects often use CocoaPods or Swift Package Manager (SPM), while Kotlin Android projects use Gradle dependencies. Each SDK's repository and documentation provide specific, detailed installation instructions, including any necessary environment configurations or build tool setups. For instance, configuring a Java project with the Okta SDK might involve adding specific repository definitions to the pom.xml file for Maven or build.gradle for Gradle, in addition to the dependency declaration. The Okta developer guides offer detailed walkthroughs for various platforms.
Quickstart example
This example demonstrates a basic integration of the Okta JavaScript SDK (@okta/okta-auth-js) for a client-side web application to handle user authentication and token management. This snippet assumes a pre-configured Okta application with a client ID and issuer URL.
import OktaAuth from '@okta/okta-auth-js';
const oktaAuth = new OktaAuth({
issuer: 'https://{yourOktaDomain}/oauth2/default',
clientId: '{yourClientId}',
redirectUri: window.location.origin + '/implicit/callback',
scopes: ['openid', 'profile', 'email']
});
async function signIn() {
await oktaAuth.signInWithRedirect();
}
async function handleRedirect() {
const originalUri = await oktaAuth.getOriginalUri();
if (originalUri === window.location.href) {
// This is not a redirect from Okta, do nothing
return;
}
try {
const tokens = await oktaAuth.handleLoginRedirect();
if (tokens) {
console.log('User logged in successfully:', tokens);
// Store tokens, update UI, redirect to protected page
const userClaims = await oktaAuth.getUser();
console.log('User claims:', userClaims);
} else if (oktaAuth.isSignInWithRedirect()) {
// This branch is hit if tokens are null but it's still a redirect flow
// It means the redirect is still processing or there was an error
console.log('Redirect is still processing...');
}
} catch (error) {
console.error('Login failed:', error);
}
}
// Call handleRedirect on page load to process any incoming redirects
handleRedirect();
// Example usage for a login button
// document.getElementById('login-button').addEventListener('click', signIn);
This JavaScript code initializes the OktaAuth client with application-specific configuration. The signInWithRedirect() method initiates the OAuth 2.0 authorization code flow with PKCE, redirecting the user to the Okta sign-in page. After successful authentication, Okta redirects the user back to the redirectUri. The handleLoginRedirect() function processes the URL parameters, exchanges the authorization code for tokens (ID token, access token, refresh token), and retrieves user information. This workflow is a standard implementation of OpenID Connect for client-side applications, as outlined in the OAuth 2.0 Authorization Code Flow specification.
For backend applications, the SDK usage differs, focusing on server-side token validation, API calls to Okta, and managing user sessions securely. For instance, a Python Flask application might use the okta-sdk-python to verify incoming access tokens from a client application before granting access to protected resources. The choice of SDK and implementation pattern depends on the application's architecture (single-page application, traditional web app, mobile, or API service) and its specific identity requirements.
Community libraries
In addition to the official SDKs, the Okta developer community contributes various libraries, integrations, and examples. These community-driven projects can offer solutions for niche use cases, specific framework integrations not officially supported, or alternative approaches to common identity challenges. Community libraries are typically hosted on platforms like GitHub and are often open-source, allowing for peer review and collaboration.
While official SDKs are recommended for core identity integrations due to direct vendor support and maintenance, community libraries can provide valuable supplementary tools. Examples might include custom UI components for authentication flows, integrations with less common programming languages or legacy systems, or specialized utilities for managing Okta resources. Developers should evaluate the maturity, maintenance, and security of community projects carefully, as they do not carry the same level of official support as Okta's first-party SDKs. The Okta Developer Blog often features community contributions and best practices, providing insights into widely used community resources.