Finding Integrations

Problem

You want to list all integrations configured on your Connect server.

Solution

Warning

You must have administrator or publisher privileges to find an integration.

Use the client.oauth.integrations.find() method to find integrations.

from posit import connect

client = connect.Client()
integrations = client.oauth.integrations.find()

The results can be transformed into a DataFrame for easy viewing and filtering.

>>> import polars as pl
>>> pl.DataFrame(integrations)
shape: (8, 8)
┌─────┬─────────────────────────────────┬──────────────────────┬──────────────────────┬────────────────────────────┬──────────────────────────────┬───────────┬─────────────────────────────────┐
id  ┆ guid                            ┆ created_time         ┆ updated_time         ┆ name                       ┆ description                  ┆ template  ┆ config                          │
------------------------
strstrstrstrstrstrstr       ┆ struct[8]                       │
╞═════╪═════════════════════════════════╪══════════════════════╪══════════════════════╪════════════════════════════╪══════════════════════════════╪═══════════╪═════════════════════════════════╡
3684f0f0ae-e328-44b0-98ba-aee6e7… ┆ 2024-07-17T21:09:36Z2024-07-18T13:26:03Z ┆ Azure                      ┆ Azure (staging)              ┆ azure     ┆ {"Confidential",null,"23a0078b… │
│ 41  ┆ 9304b050-ac0b-4b3f-b115-f0e8d8… ┆ 2024-07-18T16:52:32Z ┆ 2024-07-18T16:52:32Z ┆ Snowflake                  ┆ Snowflake (production)       ┆ snowflake ┆ {"Confidential","https://examp… │
│ 43  ┆ 5b3c3c91-6c77-4403-9852-3dd3ba… ┆ 2024-07-19T14:12:47Z ┆ 2024-08-01T17:46:00Z ┆ Custom - Databricks        ┆ Databricks / Testing         ┆ custom    ┆ {"Confidential",null,"xlqAk/IN… │
└─────┴─────────────────────────────────┴──────────────────────┴──────────────────────┴────────────────────────────┴──────────────────────────────┴───────────┴─────────────────────────────────┘

Use the connectapi client to make a direct call to the integrations endpoint.

library(connectapi)

client <- connect()
integrations <- client$GET("v1/oauth/integrations")

The results can be transformed into a DataFrame for easy viewing and filtering.

> integrations_df <- map_dfr(integrations, function(record) {
  # Extract main fields
  main_fields <- discard(record, is.list)  # Discard list fields like 'config'

  # Extract and combine the config fields with field names and values
  config <- paste(imap_chr(record$config, ~paste(.y, .x, sep = ": ")), collapse = ", ")

  # Combine both into a single list
  c(main_fields, config = config)
})
> integrations_df
# A tibble: 7 × 8
  id    guid                                 created_time         updated_time         name                           description                        template  config               
  <chr> <chr>                                <chr>                <chr>                <chr>                          <chr>                              <chr>     <chr>                
1 36    84f0f0ae-e328-44b0-98ba-aee6e775b5f0 2024-07-17T21:09:36Z 2024-07-18T13:26:03Z Azure                          "Azure (staging)"                  azure     auth_mode: Confident…
2 41    9304b050-ac0b-4b3f-b115-f0e8d8023f3f 2024-07-18T16:52:32Z 2024-07-18T16:52:32Z Snowflake                      "Snowflake (production)"           snowflake account_url: https:/
3 43    5b3c3c91-6c77-4403-9852-3dd3ba33807d 2024-07-19T14:12:47Z 2024-08-01T17:46:00Z Custom - Databricks            "Databricks / Testing"             custom    auth_mode: Confident…

Discussion

These methods provide an effective way to search for integrations when you do not know the integration unique identifier (GUID).

The code below extracts the first integration from the results that matches a given name. The snippet returns None if there are no matches or the list is empty.

>>> next((i for i in integrations if i.name == "Azure"), None)
{'id': '36', 'guid': '84f0f0ae-e328-44b0-98ba-aee6e775b5f0', 'created_time': '2024-07-17T21:09:36Z', 'updated_time': '2024-07-18T13:26:03Z', 'name': 'azure', 'description': 'Azure - Confidential', 'template': 'azure', 'config': {'auth_mode': 'Confidential', 'client_id': '23a0078b-cd0d-489f-8e00-e5006c71db9b', 'scopes': '2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default offline_access', 'tenant_id': 'a0b52785-a0b5-4a72-a6d0-13ac07ebabd7'}}

The code below extracts the first GUID from the results that matches a given name.

> library(dplyr)
> integrations_df |>
+     filter(name == "Azure") |>
+     slice(1) |>
+     pull(guid)
[1] "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
Note

The name attribute does not guarantee uniqueness, this example may not be applicable to your use case.

See also

  • For more details about the data returned in this recipe, see Get OAuth session details in the API Reference.
  • See OAuth Integrations in the User Guide to learn more about how publishers and viewers interact with OAuth integrations.
  • See OAuth Integrations in the Admin Guide to for more detailed information on how to configure OAuth integrations.