SDKs overview

Okta Identity Cloud offers a range of SDKs and client libraries designed to simplify the integration of its identity and access management functionalities into various applications. These tools abstract away the complexities of OAuth 2.0, OpenID Connect, and SAML protocols, allowing developers to focus on application logic rather than intricate security implementations. The SDKs provide methods for tasks such as user authentication, token management, and secure API access, catering to both workforce identity and customer identity use cases through its Okta Identity Cloud platform and Auth0-branded Customer Identity Cloud.

The availability of SDKs across multiple programming languages ensures broad compatibility with existing development environments. Official SDKs are actively maintained by Okta and Auth0, ensuring they are kept up-to-date with the latest security standards and platform features. Beyond official offerings, a community of developers contributes to various open-source libraries and integrations, extending the ecosystem further.

Official SDKs by language

Okta provides official SDKs and client libraries for several popular programming languages, each designed to integrate with the Okta Identity Cloud. These libraries handle common identity flows such as sign-in, sign-up, multifactor authentication (MFA), and secure API calls. Developers can find detailed setup instructions and usage examples within the Okta developer documentation.

Language Package/Library Installation Command (Example) Maturity
JavaScript (Browser) @okta/okta-auth-js npm install @okta/okta-auth-js Stable
JavaScript (Node.js) @okta/jwt-verifier npm install @okta/jwt-verifier Stable
Python okta-sdk-python pip install okta-sdk-python Stable
Java okta-sdk-java Maven: <dependency><groupId>com.okta.sdk</groupId><artifactId>okta-sdk-api</artifactId><version>...</version></dependency> Stable
Go okta-sdk-golang go get github.com/okta/okta-sdk-golang Stable
PHP okta/okta-sdk-php composer require okta/okta-sdk-php Stable
Ruby okta-ruby gem install okta-ruby Stable
.NET Okta.Sdk Install-Package Okta.Sdk (NuGet) Stable

For mobile development, Okta also provides SDKs for iOS and Android, enabling native application integration. These mobile SDKs focus on secure authentication flows, including biometrics and device-specific security features.

Installation

Installation methods for Okta SDKs typically follow standard package management practices for each respective language. Detailed instructions are provided in the Okta SDKs and Libraries documentation.

JavaScript (npm)

For browser-based applications using @okta/okta-auth-js:

npm install @okta/okta-auth-js --save

For Node.js applications, such as for JWT verification:

npm install @okta/jwt-verifier --save

Python (pip)

Install the Okta Python SDK:

pip install okta-sdk-python

Java (Maven)

Add the following dependency to your pom.xml file:

<dependency>
    <groupId>com.okta.sdk</groupId>
    <artifactId>okta-sdk-api</artifactId>
    <version>3.0.0</version> <!-- Check for the latest version -->
</dependency>
<dependency>
    <groupId>com.okta.sdk</groupId>
    <artifactId>okta-sdk-impl</artifactId>
    <version>3.0.0</version> <!-- Check for the latest version -->
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>com.okta.commons</groupId>
    <artifactId>okta-commons-lang</artifactId>
    <version>1.0.0</version> <!-- Check for the latest version -->
</dependency>

Go (go get)

To install the Go SDK:

go get github.com/okta/okta-sdk-golang

PHP (Composer)

Include the SDK in your project using Composer:

composer require okta/okta-sdk-php

Ruby (Gem)

Add to your Gemfile:

gem 'okta-ruby'

Then run bundle install, or install directly:

gem install okta-ruby

.NET (NuGet)

Install the NuGet package from the Package Manager Console:

Install-Package Okta.Sdk

Or via the .NET CLI:

dotnet add package Okta.Sdk

Quickstart example

The following quickstart example demonstrates a basic client-side authentication flow using the Okta JavaScript SDK (@okta/okta-auth-js) to sign in a user and retrieve their ID token. This example assumes you have an Okta application configured with a client ID and issuer URL.

JavaScript (Browser)

First, ensure you have an HTML file with a login button and a div to display user info:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Okta Login</title>
</head>
<body>
    <h1>Welcome to the Okta App</h1>
    <button id="login-button">Login</button>
    <div id="user-info"></div>

    <script src="./node_modules/@okta/okta-auth-js/dist/okta-auth-js.min.js"></script>
    <script>
        const oktaAuth = new OktaAuth({
            issuer: 'https://{yourOktaDomain}/oauth2/default',
            clientId: '{yourClientId}',
            redirectUri: window.location.origin + '/callback',
            scopes: ['openid', 'profile', 'email']
        });

        document.getElementById('login-button').addEventListener('click', async () => {
            await oktaAuth.signInWithRedirect();
        });

        async function handleLoginRedirect() {
            const userInfoDiv = document.getElementById('user-info');
            if (window.location.pathname === '/callback') {
                const { tokens } = await oktaAuth.handleLoginRedirect();
                if (tokens) {
                    const idToken = tokens.idToken;
                    userInfoDiv.innerHTML = `<p>Welcome, ${idToken.claims.name}!</p><p>Email: ${idToken.claims.email}</p>`;
                    console.log('ID Token:', idToken);
                }
            } else {
                const isAuthenticated = await oktaAuth.isAuthenticated();
                if (isAuthenticated) {
                    const user = await oktaAuth.getUser();
                    userInfoDiv.innerHTML = `<p>Welcome back, ${user.name}!</p><p>Email: ${user.email}</p>`;
                }
            }
        }

        handleLoginRedirect();
    </script>
</body>
</html>

Replace {yourOktaDomain} and {yourClientId} with your actual Okta values. Configure a redirect URI of http://localhost:8080/callback (or your chosen URL) in your Okta application settings. This example demonstrates initiating a login flow and processing the redirect response to display user information. For a full tutorial, refer to the Okta Sign-in to SPA guide.

Community libraries

In addition to the official SDKs, the Okta and Auth0 ecosystems benefit from community-contributed libraries and integrations. These often address specific frameworks, niche use cases, or provide alternative implementations. While not officially supported by Okta, they can offer valuable solutions for developers.

  • Framework-specific integrations: Community members often develop wrappers or integrations for popular front-end frameworks like React, Angular, and Vue.js that might extend beyond the official offerings.
  • Specialized tools: Libraries for specific authentication flows, testing utilities, or command-line tools that interact with Okta APIs.
  • Language extensions: Contributions for languages or environments where an official SDK might not be the primary focus.

Developers are encouraged to explore community forums and GitHub repositories to discover these resources. However, when using community-contributed libraries, it is important to review their maintenance status, security practices, and compatibility with the latest Okta API versions. For example, the OAuth 2.0 and OpenID Connect specifications, which Okta implements, are standardized protocols that many community libraries also adhere to.

The Okta Developer Blog often highlights community projects and best practices, serving as a resource for discovering useful integrations and staying informed about the broader ecosystem.