Query Okta Data in DataGrip



Create a Data Source for Okta in DataGrip and use SQL to query live Okta data.

DataGrip is a database IDE that allows SQL developers to query, create, and manage databases. When paired with the CData JDBC Driver for Okta, DataGrip can work with live Okta data. This article shows how to establish a connection to Okta data in DataGrip.

Create a New Driver Definition for Okta

The steps below describe how to create a new Data Source in DataGrip for Okta.

  1. In DataGrip, click File -> New > Project and name the project
  2. In the Database Explorer, click the plus icon () and select Driver.
  3. In the Driver tab:
    • Set Name to a user-friendly name (e.g. "CData Okta Driver")
    • Set Driver Files to the appropriate JAR file. To add the file, click the plus (), select "Add Files," navigate to the "lib" folder in the driver's installation directory and select the JAR file (e.g. cdata.jdbc.okta.jar).
    • Set Class to cdata.jdbc.okta.Okta.jar
    Additionally, in the advanced tab you can change driver properties and some other settings like VM Options, VM environment, VM home path, DBMS, etc
    • For most cases, change the DBMS type to "Unknown" in Expert options to avoid native SQL Server queries (Transact-SQL), which might result in an invalid function error
  4. Click "Apply" then "OK" to save the Connection

Configure a Connection to Okta

  1. Once the connection is saved, click the plus (), then "Data Source" then "CData Okta Driver" to create a new Okta Data Source.
  2. In the new window, configure the connection to Okta with a JDBC URL.

    Built-in Connection String Designer

    For assistance in constructing the JDBC URL, use the connection string designer built into the Okta JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

    java -jar cdata.jdbc.okta.jar

    Fill in the connection properties and copy the connection string to the clipboard.

    To connect to Okta, set the Domain connection string property to your Okta domain.

    You will use OAuth to authenticate with Okta, so you need to create a custom OAuth application.

    Creating a Custom OAuth Application

    From your Okta account:

    1. Sign in to your Okta developer edition organization with your administrator account.
    2. In the Admin Console, go to Applications > Applications.
    3. Click Create App Integration.
    4. For the Sign-in method, select OIDC - OpenID Connect.
    5. For Application type, choose Web Application.
    6. Enter a name for your custom application.
    7. Set the Grant Type to Authorization Code. If you want the token to be automatically refreshed, also check Refresh Token.
    8. Set the callback URL:
      • For desktop applications and headless machines, use http://localhost:33333 or another port number of your choice. The URI you set here becomes the CallbackURL property.
      • For web applications, set the callback URL to a trusted redirect URL. This URL is the web location the user returns to with the token that verifies that your application has been granted access.
    9. In the Assignments section, either select Limit access to selected groups and add a group, or skip group assignment for now.
    10. Save the OAuth application.
    11. The application's Client Id and Client Secret are displayed on the application's General tab. Record these for future use. You will use the Client Id to set the OAuthClientId and the Client Secret to set the OAuthClientSecret.
    12. Check the Assignments tab to confirm that all users who must access the application are assigned to the application.
    13. On the Okta API Scopes tab, select the scopes you wish to grant to the OAuth application. These scopes determine the data that the app has permission to read, so a scope for a particular view must be granted for the driver to have permission to query that view. To confirm the scopes required for each view, see the view-specific pages in Data Model < Views in the Help documentation.
  3. Set URL to the connection string, e.g., jdbc:okta:Domain=dev-44876464.okta.com;InitiateOAuth=GETANDREFRESH
  4. Click "Apply" and "OK" to save the connection string

At this point, you will see the data source in the Data Explorer.

Execute SQL Queries Against Okta

To browse through the Okta entities (available as tables) accessible through the JDBC Driver, expand the Data Source.

To execute queries, right click on any table and select "New" -> "Query Console."

In the Console, write the SQL query you wish to execute. For example: SELECT Id, ProfileFirstName FROM Users WHERE Status = 'Active'

Download a free, 30-day trial of the CData JDBC Driver for Okta and start working with your live Okta data in DataGrip. Reach out to our Support Team if you have any questions.

Ready to get started?

Download a free trial of the Okta Driver to get started:

 Download Now

Learn more:

Okta Icon Okta JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Okta.