SSO with Management SDKs

You must configure SSO for each tenant independently. These settings can be configured via the Descope Console, the SSO Setup Suite, the Management tenants SSO API, or the SDK as shown below.

To start an SSO login (redirect + code exchange), use the auth SSO API or SSO with Backend SDKs — that is separate from configuring a tenant's IdP connection.

These are all of the SDK functions you can use in your backend to configure and manage SSO for your tenants.

Install SDK

Terminal
npm i --save @descope/node-sdk
Terminal
pip3 install descope
Terminal
go get github.com/descope/go-sdk
// Include the following in your `pom.xml` (for Maven)
<dependency>
    <artifactId>java-sdk</artifactId>
    <groupId>com.descope</groupId>
    <version>sdk-version</version> // Check https://github.com/descope/descope-java/releases for the latest versions
</dependency>
Terminal
gem install descope

Import and initialize Management SDK

import DescopeClient from '@descope/node-sdk';

const managementKey = "xxxx"

try{
    //  baseUrl="<URL>" // When initializing the Descope client, you can also configure the baseUrl ex: https://auth.company.com  - this is useful when you utilize a custom domain within your Descope project.
    const descopeClient = DescopeClient({ projectId: '__ProjectID__', managementKey: managementKey });
} catch (error) {
    // handle the error
    console.log("failed to initialize: " + error)
}
from descope import (
    REFRESH_SESSION_TOKEN_NAME,
    SESSION_TOKEN_NAME,
    AuthException,
    DeliveryMethod,
    DescopeClient,
    AssociatedTenant,
    RoleMapping,
    AttributeMapping
)

management_key = "xxxx"

try:
    # You can configure the baseURL by setting the env variable Ex: export DESCOPE_BASE_URI="https://auth.company.com  - this is useful when you utilize a custom domain within your Descope project."
    descope_client = DescopeClient(project_id='__ProjectID__', management_key=management_key)
except Exception as error:
    # handle the error
    print ("failed to initialize. Error:")
    print (error)
import "github.com/descope/go-sdk/descope"
import "github.com/descope/go-sdk/descope/client"
import "fmt"

// Utilizing the context package allows for the transmission of context capabilities like cancellation
//      signals during the function call. In cases where context is absent, the context.Background()
//      function serves as a viable alternative.
//      Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
import (
	"context"
)

managementKey = "xxxx"

// DescopeBaseURL // within the client.Config, you can also configure the baseUrl ex: https://auth.company.com  - this is useful when you utilize a custom domain within your Descope project.
descopeClient, err := client.NewWithConfig(&client.Config{ProjectID:"__ProjectID__", managementKey:managementKey})
if err != nil {
    // handle the error
    log.Println("failed to initialize: " + err.Error())
}
import com.descope.client;

// Initialized after setting the DESCOPE_PROJECT_ID env var (and optionally DESCOPE_MANAGEMENT_KEY)
var descopeClient = new DescopeClient();

// ** Or directly **
var descopeClient = new DescopeClient(Config.builder()
        .projectId("__ProjectID__")
        .managementKey("management-key")
        .build());
require 'descope'

descope_client = Descope::Client.new(
  {
    project_id: '__ProjectID__',
    management_key: 'management_key'
  }
)

Identity Provider (IdP) Details

You can either set the identity provider details using a metadata URL from the IdP or enter them in the console. The values for each field can be obtained from the admin console of the identity provider.

// Configure SSO setting for a tenant manually. Alternatively, `configure_via_metadata` can be used instead.
// Args:
//    tenantId (str): The tenant ID to be configured
const tenantId = "xxxxxx"
//    idpURL (str): The URL for the identity provider.
const idpURL = "https://example_idpURL.com"
//    entityId (str): The entity ID (in the IDP).
const entityId = "descope"
//    idpCert (str): The certificate provided by the IDP.
const idpCert = "xxxxxx"
//    redirectURL (str): An Optional Redirect URL after successful authentication.
const redirectURL = "https://example_descope_app.com/saml"
//    domain (str): An optional domain used to associate users authenticating via SSO with this tenant
const domain = "example_descope_app.com"

let resp = await descopeClient.management.sso.configureSettings(tenantId, idpURL, idpCert, entityId, redirectURL, domain)
if (!resp.ok) {
  console.log("Unable to configure tenant sso.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully configured sso configuration for tenant manually.")
  console.log(resp.data)
}

// Configure SSO setting for am IDP metadata URL. Alternatively, `configure` can be used instead.
// Args:
//   tenantId (str): The tenant ID to be configured
const tenantId = "xxxxxx"
//   idpMetadataURL (str): The URL to fetch SSO settings from.
const idpMetadataURL = "https://example_idpURL.com/api/v1/apps/xxxxxxx/sso/saml/metadata?"
//    redirectURL (str): An Optional Redirect URL after successful authentication.
const redirectURL = "https://example_descope_app.com/saml"
//    domain (str): An optional domain used to associate users authenticating via SSO with this tenant
const domain = "example_descope_app.com"

let resp = await descopeClient.management.sso.configureMetadata(tenantId, idpMetadataURL, redirectURL, domain)
if (!resp.ok) {
  console.log("Unable to configure tenant sso.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully configured sso configuration for tenant via metadata url.")
  console.log(resp.data)
}
# Configure SSO setting for a tenant manually. Alternatively, `configure_via_metadata` can be used instead.
# Args:
#    tenant_id (str): The tenant ID to be configured
tenant_id = "xxxxxx"
#    idp_url (str): The URL for the identity provider.
idp_url = "https://example_idp_url.com"
#    entity_id (str): The entity ID (in the IDP).
entity_id = "descope"
#    idp_cert (str): The certificate provided by the IDP.
idp_cert = "xxxxxx"
#    redirect_url (str): An Optional Redirect URL after successful authentication.
redirect_url = "https://example_descope_app.com/saml"
#    domain (str): An optional domain used to associate users authenticating via SSO with this tenant
domain = "example_descope_app.com"

try:
  resp = descope_client.mgmt.sso.configure(tenant_id=tenant_id, idp_url=idp_url, entity_id=entity_id, idp_cert=idp_cert, redirect_url=redirect_url, domain=domain)
  print ("Successfully configured sso configuration for tenant manually")
except AuthException as error:
  print ("Unable to configure tenant sso.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))

# Configure SSO setting for am IDP metadata URL. Alternatively, `configure` can be used instead.
# Args:
#   tenant_id (str): The tenant ID to be configured
tenant_id = "xxxxxx"
#   idp_metadata_url (str): The URL to fetch SSO settings from.
idp_metadata_url = "https://example_idp_url.com/api/v1/apps/xxxxxxx/sso/saml/metadata?"
#    redirect_url (str): An Optional Redirect URL after successful authentication.
redirect_url = "https://example_descope_app.com/saml"
#    domain (str): An optional domain used to associate users authenticating via SSO with this tenant
domain = "example_descope_app.com"

try:
  resp = descope_client.mgmt.sso.configure_via_metadata(tenant_id=tenant_id, idp_metadata_url=idp_metadata_url, redirect_url=redirect_url, domain=domain)
  print ("Successfully configured sso configuration for tenant via metadata url")
except AuthException as error:
  print ("Unable to configure tenant sso.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Configure SSO setting for a tenant manually. Alternatively, `configure_via_metadata` can be used instead.
// Args:
//    ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//    tenantID (str): The tenant ID to be configured
tenantID := "xxxxxx"
//    idpURL (str): The URL for the identity provider.
idpURL := "https://example_idp_url.com"
//    idpCert (str): The certificate provided by the IDP.
idpCert := "xxxxxx"
//    entityID (str): The entity ID (in the IDP).
entityID := "descope"
//    redirectURL (str): An Optional Redirect URL after successful authentication.
redirectURL := "https://example_descope_app.com/saml"
//    domain (str): An optional domain used to associate users authenticating via SSO with this tenant
domain := "example_descope_app.com"

err := descopeClient.Management.SSO().ConfigureSettings(ctx, tenantID, idpURL, idpCert, entityID, redirectURL, domain)
if  (err != nil){
  fmt.Println("Unable to configure tenant sso: ", err)
} else {
  fmt.Println("Successfully configured sso configuration for tenant manually.")
}

// Configure SSO setting for a tenant manually. Alternatively, `configure_via_metadata` can be used instead.
// Args:
//    ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//    tenantID (str): The tenant ID to be configured
tenantID := "xxxxxx"
//   idpMetadataURL (str): The URL to fetch SSO settings from.
idpMetadataURL := "https://example_idp_url.com/api/v1/apps/xxxxxxx/sso/saml/metadata?"
//    redirectURL (str): An Optional Redirect URL after successful authentication.
redirectURL := "https://example_descope_app.com/saml"
//    domain (str): An optional domain used to associate users authenticating via SSO with this tenant
domain := "example_descope_app.com"

err := descopeClient.Management.SSO().ConfigureMetadata(ctx, tenantID, idpMetadataURL, redirectURL, domain)
if  (err != nil){
  fmt.Println("Unable to configure tenant sso: ", err)
} else {
  fmt.Println("Successfully configured sso configuration for tenant via metadata url.")
}
SsoService ss = descopeClient.getManagementServices().getSsoService();
// You can configure SSO settings manually by setting the required fields directly
String tenantId = "tenant-id"; // Which tenant this configuration is for
String idpUrl = "https://idp.com";
String entityId = "my-idp-entity-id";
String idpCert = "<your-cert-here>";
String redirectUrl = "https://my-app.com/handle-saml"; // Global redirect URL for SSO/SAML
String domain = "domain.com"; // Users logging in from this domain will be logged in to this tenant

try {
    ss.configureSettings(tenantId, idpUrl, idpCert, entityId, redirectUrl, domain);
} catch (DescopeException de) {
    // Handle the error
}

// Alternatively, configure using an SSO metadata URL
try {
    ss.configureMetadata(tenantId, "https://idp.com/my-idp-metadata");
} catch (DescopeException de) {
    // Handle the error
}

Configure SSO Redirect URL

You can update only the redirect URLs for a specific SSO configuration without touching the rest of the IdP settings. Leave either URL unset (using whichever "no value" convention your chosen SDK uses, such as nil, None, or null) to leave it unchanged, but make sure to provide a valid URL for at least one of them.

// Args:
//    tenantId (str): The tenant ID to be configured.
const tenantId = "xxxxxx"
//    samlRedirectUrl (str): Optional redirect URL for SAML SSO. Leave undefined to leave unchanged.
const samlRedirectUrl = "https://example_descope_app.com/saml"
//    oauthRedirectUrl (str): Optional redirect URL for OAuth SSO. Leave undefined to leave unchanged.
const oauthRedirectUrl = "https://example_descope_app.com/oauth"
//    ssoId (str): Optional SSO configuration ID (only needed if the tenant has multiple SSO configs).
const ssoId = ""

let resp = await descopeClient.management.sso.configureSSORedirectURL(tenantId, samlRedirectUrl, oauthRedirectUrl, ssoId)
if (!resp.ok) {
  console.log("Unable to configure SSO redirect URL.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully configured SSO redirect URL.")
}
# Args:
#    tenant_id (str): The tenant ID to be configured.
tenant_id = "xxxxxx"
#    saml_redirect_url (str): Optional redirect URL for SAML SSO. Pass None to leave unchanged.
saml_redirect_url = "https://example_descope_app.com/saml"
#    oauth_redirect_url (str): Optional redirect URL for OAuth SSO. Pass None to leave unchanged.
oauth_redirect_url = "https://example_descope_app.com/oauth"
#    sso_id (str): Optional SSO configuration ID (only needed if the tenant has multiple SSO configs).
sso_id = None

try:
  descope_client.mgmt.sso.configure_sso_redirect_url(tenant_id=tenant_id, saml_redirect_url=saml_redirect_url, oauth_redirect_url=oauth_redirect_url, sso_id=sso_id)
  print ("Successfully configured SSO redirect URL.")
except AuthException as error:
  print ("Unable to configure SSO redirect URL.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//    ctx: context.Context - Application context.
ctx := context.Background()
//    tenantID (string): The tenant ID to be configured.
tenantID := "xxxxxx"
//    samlRedirectURL (*string): Optional redirect URL for SAML SSO. Pass nil to leave unchanged.
samlRedirectURL := "https://example_descope_app.com/saml"
//    oauthRedirectURL (*string): Optional redirect URL for OAuth SSO. Pass nil to leave unchanged.
oauthRedirectURL := "https://example_descope_app.com/oauth"
//    ssoID (string): The SSO configuration ID (use "" if the tenant has only one SSO config).
ssoID := ""

err := descopeClient.Management.SSO().ConfigureSSORedirectURL(ctx, tenantID, &samlRedirectURL, &oauthRedirectURL, ssoID)
if err != nil {
  fmt.Println("Unable to configure SSO redirect URL: ", err)
} else {
  fmt.Println("Successfully configured SSO redirect URL.")
}
SsoService ss = descopeClient.getManagementServices().getSsoService();
// Args:
String tenantId = "tenant-id"; // The tenant ID to be configured
String samlRedirectUrl = "https://my-app.com/handle-saml"; // Optional redirect URL for SAML SSO. Pass null to leave unchanged.
String oauthRedirectUrl = "https://my-app.com/handle-oauth"; // Optional redirect URL for OAuth SSO. Pass null to leave unchanged.
String ssoId = null; // Optional SSO configuration ID (only needed if the tenant has multiple SSO configs)

try {
    ss.configureSSORedirectURL(tenantId, samlRedirectUrl, oauthRedirectUrl, ssoId);
} catch (DescopeException de) {
    // Handle the error
}
// Args:
//    TenantId (string): The tenant ID to be configured.
//    SamlRedirectUrl (string?): Optional redirect URL for SAML SSO. Leave null to leave unchanged.
//    OauthRedirectUrl (string?): Optional redirect URL for OAuth SSO. Leave null to leave unchanged.
//    SsoId (string?): Optional SSO configuration ID (only needed if the tenant has multiple SSO configs).
var request = new ConfigureSSORedirectURLRequest
{
    TenantId = "tenant-id",
    SamlRedirectUrl = "https://example_descope_app.com/saml",
    OauthRedirectUrl = "https://example_descope_app.com/oauth",
};

await client.Mgmt.V1.Sso.Redirect.PostAsync(request);
// Args:
//    tenantId (string): The tenant ID to be configured.
$tenantId = "xxxxxx";
//    samlRedirectUrl (?string): Optional redirect URL for SAML SSO. Pass null to leave unchanged.
$samlRedirectUrl = "https://example_descope_app.com/saml";
//    oauthRedirectUrl (?string): Optional redirect URL for OAuth SSO. Pass null to leave unchanged.
$oauthRedirectUrl = "https://example_descope_app.com/oauth";
//    ssoId (string): Optional SSO configuration ID (only needed if the tenant has multiple SSO configs).
$ssoId = "";

try {
    $descopeSDK->management->sso->configureSSORedirectURL($tenantId, $samlRedirectUrl, $oauthRedirectUrl, $ssoId);
    echo "Successfully configured SSO redirect URL.\n";
} catch (\Descope\SDK\Exception\AuthException $e) {
    echo "Unable to configure SSO redirect URL: " . $e->getMessage() . "\n";
}

Load SSO Configuration

Descope allows you to load the SSO config for a specified tenant.

// Args:
//    tenantId (str): The tenant ID to get the SSO configuration from.
const tenantId = "xxxxxx"
//    ssoId (str): The SSO ID to get the SSO configuration for if the tenant has multiple SSO configs
const ssoId = "xxxxxx"

// You can pass ssoId in case you want to load a specific SSO configuration
const ssoSettings = await descopeClient.management.sso.loadSettings('tenantId', 'ssoId');

// You can get all configured SSO settings for a specific tenant if the tenant has multiple SSO configs
const allSSOSettings = await descopeClient.management.sso.loadAllSettings('tenantId');
# Args:
#    tenant_id (str): The tenant ID to get the SSO configuration from.
tenant_id = "xxxxxxx"

sso_settings_res = descope_client.mgmt.sso.load_settings("tenant-id")
// Args:
//    tenantId (str): The tenant ID to get the SSO configuration from.
const tenantId = "xxxxxx"
//    ssoId (str): The SSO ID to get the SSO configuration for if the tenant has multiple SSO configs
const ssoId = "xxxxxx"

// You can pass ssoId in case you want to load a specific SSO configuration
ssoSettings, err := descopeClient.Management.SSO().LoadSettings(context.Background(), "tenantId", "ssoId")

// You can get all configured SSO settings for a specific tenant if the tenant has multiple SSO configs
allSSOSettings, err := descopeClient.Management.SSO().LoadAllSettings(context.Background(), "tenantId");
SsoService ss = descopeClient.getManagementServices().getSsoService();

// You can get SSO settings for a specific tenant ID
SSOSettingsResponse resp = ss.loadSettings("tenant-id");

Delete SSO Configuration

Descope allows you to delete the SSO config for a specified tenant. Use caution with this SDK call as it will remove the configuration and is irreversible.

// Args:
//   tenantId (str): The tenant ID to delete the SSO configuration from.
const tenantId = "xxxxxx"

// You can optionally pass in the ssoId if the tenant has multiple SSO configs
let resp = await descopeClient.management.sso.deleteSettings(tenantId, ssoId)
if (!resp.ok) {
  console.log("Unable to delete the sso configuration from tenant.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully deleted sso configuration from tenant.")
}
# Args:
#    tenant_id (str): The tenant ID to delete the SSO configuration from.
tenant_id = "xxxxxxx"

try:
  descope_client.mgmt.sso.delete_settings(tenant_id=tenant_id)
  print ("Successfully deleted sso configuration from tenant.")
except AuthException as error:
  print ("Unable to delete the sso configuration from tenant.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//    ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//    tenantID (str): The tenant ID to delete the SSO configuration from.
tenantID := "xxxxxxx"

// You can optionally pass in the ssoId if the tenant has multiple SSO configs
err := descopeClient.Management.SSO().DeleteSettings(ctx, tenantID, ssoId)
if  (err != nil){
  fmt.Println("Unable to delete the sso configuration from tenant: ", err)
} else {
  fmt.Println("Successfully deleted sso configuration from tenant.")
}
SsoService ss = descopeClient.getManagementServices().getSsoService();
// You can get SSO settings for a specific tenant ID
try {
    SSOSettingsResponse resp = ss.deleteSettings("tenant-id");
} catch (DescopeException de) {
    // Handle the error
}

SSO Mapping

SSO User Attribute Mapping

In this section of the console, you can setup mapping for user attributes. After you set up the mapping, each user that signs into your application will get these attributes assigned from the IdP.

Note

Descope also allows you to map attributes from your IdP to custom user attributes when configuring your attribute mapping.

Groups Mapping

In this part of SSO configuration, you can map SSO groups from your IdP to roles defined in Descope service. The group-to-role mapping will automatically populate the user's roles at the time of sign-in. The roles are included in the session token after successful authentication. It is important to note, this function overrides any previous mapping (even when empty).

// Args:
//   tenantId (str): The tenant ID to be configured
const tenantId = "xxxxxx"
//    roleMappings (RoleMapping): A mapping between IDP groups and Descope roles.
const roleMapping = { groups: ['IDP_ADMIN'], roleName: 'Tenant Admin'}
//    attributeMapping (AttributeMapping): A mapping between IDP user attributes and descope attributes.
const attributeMapping = {name: "IDP_NAME", phoneNumber: "IDP_PHONE",}

let resp = await descopeClient.management.sso.configureMapping(tenantId, roleMapping, attributeMapping)
if (!resp.ok) {
  console.log("Unable to configured sso role and attribute mapping.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully configured sso role and attribute mapping.")
}
# Args:
#    tenant_id (str): The tenant ID to be configured
tenant_id = "xxxxxxx"
#    role_mappings (List[RoleMapping]): A mapping between IDP groups and Descope roles.
role_mappings = [RoleMapping(["IDP_ADMIN"], "Tenant Admin")]
#    attribute_mapping (AttributeMapping): A mapping between IDP user attributes and descope attributes.
attribute_mapping = AttributeMapping(name="IDP_NAME", phone_number="IDP_PHONE")

try:
  descope_client.mgmt.sso.mapping(tenant_id=tenant_id, role_mappings=role_mappings, attribute_mapping=attribute_mapping)
  print ("Successfully configured sso role and attribute mapping.")
except AuthException as error:
  print ("Unable to configured sso role and attribute mapping.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//    ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//    tenantID (str): The tenant ID to be configured
tenantID := "xxxxxxx"
//    roleMappings (List[RoleMapping]): A mapping between IDP groups and Descope roles.
roleMappings := []*descope.RoleMapping{{Groups: []string{"IDP_ADMIN"}, Role: "Tenant Admin"}}
//    attributeMapping (AttributeMapping): A mapping between IDP user attributes and descope attributes.
attributeMapping := &descope.AttributeMapping {Name: "IDP_NAME", PhoneNumber: "IDP_PHONE",}

err := descopeClient.Management.SSO().ConfigureMapping(ctx, tenantID, roleMappings, attributeMapping)
if  (err != nil){
  fmt.Println("Unable to configured sso role and attribute mapping: ", err)
} else {
  fmt.Println("Successfully configured sso role and attribute mapping.")
}
SsoService ss = descopeClient.getManagementServices().getSsoService();
// Map IDP groups to Descope roles, or map user attributes.
// This function overrides any previous mapping (even when empty). Use carefully.
List<RoleMapping> rm = Arrays.asList(new RoleMapping(Arrays.asList("Groups"), "Tenant Role"));
AttributeMapping am = new AttributeMapping("Tenant Name", "Tenant Email", "Tenant Phone Num", "Tenant Group");
try {
    ss.configureMapping(tenantId, rm, am);
} catch (DescopeException de) {
    // Handle the error
}

SSO Group Management

The Descope SDKs make the SSO Groups available for being loaded. The below covers the available functions.

Load All Groups

Descopers can load all groups for a given tenant, the below covers examples of this.

// Args:
//  tenantId (str): Tenant ID to load groups from.
const tenantId = "xxxxx"

const resp = await descopeClient.management.group.loadAllGroups(tenantId)
if (!resp.ok) {
  console.log(resp)
  console.log("Unable to load all groups.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully loaded all groups.")
  console.log(resp.data)
}
# Args:
#   tenant_id (str): Tenant ID to load groups from.
tenant_id = "xxxxx"

try:
    resp = descope_client.mgmt.group.load_all_groups(tenant_id=tenant_id)
    print ("Successfully loaded all groups.")
    print(resp)
except AuthException as error:
    print ("Unable to load all groups.")
    print ("Status Code: " + str(error.status_code))
    print ("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  tenantID (str): Tenant ID to load groups from.
tenantID := "xxxx"

resp, err := descopeClient.Management.Group().LoadAllGroups(ctx, tenantID)
if  (err != nil){
  fmt.Println("Unable to load all groups: ", err)
} else {
  fmt.Println("Successfully loaded all groups: ", resp)
}
// Load all groups for a given tenant id
GroupService gs = descopeClient.getManagementServices().getGroupService();
try {
    List<Group> groups = gs.loadAllGroups("tenant-id");
    for (Group g : groups) {
        // Do something
    }
} catch (DescopeException de) {
    // Handle the error
}

Load All Groups for Members

Descopers can load all groups for members based on login IDs and user IDs, the below covers examples of this.

// Args:
//  tenantId (str): Tenant ID to load groups from.
const tenantId = "xxxxx"
//  userIDs (List[str]): Optional List of user IDs, with the format of "U2J5ES9S8TkvCgOvcrkpzUgVTEBM" (example), which can be found on the user's JWT.
const userIds = []
//  loginIDs (List[str]): Optional List of login IDs, how the users identify when logging in.
const loginIds = []

const resp = await descopeClient.management.group.loadAllGroupsForMembers(tenantId, userIds, loginIds)
if (!resp.ok) {
  console.log(resp)
  console.log("Unable to load all groups for members.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully loaded all groups for members.")
  console.log(resp.data)
}
# Args:
#   tenant_id (str): Tenant ID to load groups from.
tenant_id = "xxxxx"
#   login_ids (List[str]): Optional List of login IDs, how the users identify when logging in.
login_ids = ["TestUser1","TestUser1"]
#   user_ids (List[str]): Optional List of user IDs, with the format of "U2J5ES9S8TkvCgOvcrkpzUgVTEBM" (example), which can be found on the user's JWT.
user_ids = ["U2J5ES9S8TkvCgOvcrkpzUgVTEBM","U2J5ES9S8TkvCgOvcrkpzUgVxtz"]


try:
  resp = descope_client.mgmt.group.load_all_groups_for_members(tenant_id=tenant_id, login_ids=login_ids, user_ids=user_ids)
  print ("Successfully loaded all groups for members.")
  print(resp)
except AuthException as error:
  print ("Unable to load all groups for members.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  tenantID (str): Tenant ID to load groups from.
tenantID := "xxxx"
//  userIDs (List[str]): Optional List of user IDs, with the format of "U2J5ES9S8TkvCgOvcrkpzUgVTEBM" (example), which can be found on the user's JWT.
userIDs := []string{"U2J5ES9S8TkvCgOvcrkpzUgVTEBM","U2J5ES9S8TkvCgOvcrkpzUgVxtz"}
//  loginIDs (List[str]): Optional List of login IDs, how the users identify when logging in.
loginIDs := []string{"TestUser1","TestUser1"}

resp, err := descopeClient.Management.Group().LoadAllGroupsForMembers(ctx, tenantID, userIDs, loginIDs)
if  (err != nil){
  fmt.Println("Unable to load all groups for members: ", err)
} else {
  fmt.Println("Successfully loaded all groups for members: ", resp)
}
// Load all groups for the given user/login IDs (can be found in the user's JWT, used for sign-in)
try {
    List<Group> groups = gs.loadAllGroupsForMembers("tenant-id",
            Arrays.asList("user-id-1", "user-id-2"),
            Arrays.asList("login-id-1", "login-id-2"));
    for (Group g : groups) {
        // Do something
    }
} catch (DescopeException de) {
    // Handle the error
}

Load All Group Members

Descopers can load all groups members based on tenant ID and group ID, the below covers examples of this.

// Args:
//  tenantId (str): Tenant ID to load groups from.
const tenantId = "xxxxx"
//  groupId (str): Group ID to load members for.
const groupId = "xxxx"

const res = await descopeClient.management.group.loadAllGroupMembers(tenantId, groupId)
if (!resp.ok) {
  console.log(resp)
  console.log("Unable to load all group members.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully loaded all group members.")
  console.log(resp.data)
}
# Args:
#   tenant_id (str): Tenant ID to load groups from.
tenant_id = "xxxxx"
#   group_id (str): Group ID to load members for.
group_id = "xxxx"

try:
  resp = descope_client.mgmt.group.load_all_group_members(tenant_id=tenant_id, group_id=group_id)
  print ("Successfully loaded all group members.")
  print(resp)
except AuthException as error:
  print ("Unable to load all group members.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  tenantID (str): Tenant ID to load groups from.
tenantID := "xxxx"
//  groupID (str): Group ID to load members for.
groupID := "xxxx"

resp, err := descopeClient.Management.Group().LoadAllGroupMembers(ctx, tenantID, groupID)
if  (err != nil){
  fmt.Println("Unable to load all group members: ", err)
} else {
  fmt.Println("Successfully loaded all group members: ", resp)
}
// Load all group's members by the given group id
try {
    List<Group> groups = gs.loadAllGroupMembers("tenant-id", "group-id");
    for (Group g : groups) {
        // Do something
    }
} catch (DescopeException de) {
    // Handle the error
}

Generate an SSO admin link for a tenant that allows a tenant administrator to configure SSO settings. The generated link can be sent to tenant administrators via email or displayed in your application. Once accessed, the link allows the administrator to configure their tenant's SAML or OIDC SSO settings through a guided interface.

The expiration parameter is a duration in seconds.

Therefore, to retrieve a link valid for 6 hours, pass 21600.

// Args:
//   tenantId (string): The ID of the tenant for which to generate the SSO configuration link.
const tenantId = "my-tenant-id";
//   expireDuration (number): Expiration duration in seconds. For a 6-hour link, use 21600.
const expireDuration = 21600; // 6 hours
//   ssoId (string, optional): SSO identifier for the tenant.
const ssoId = "my-sso-id";
//   email (string, optional): Email address associated with the admin.
const email = "admin@example.com";
//   templateId (string, optional): Template ID to use for the configuration page.
const templateId = "my-template-id";
//   actorId (string, optional): When provided, this id is recorded as the audit actor for actions
//     performed inside the SSO Setup Suite (instead of the temporary user). Used as-is for
//     audit attribution and is not validated.
const actorId = "my-admin-actor-id";

try {
  const resp = await descopeClient.management.tenant.generateSSOConfigurationLink(
    tenantId,
    expireDuration,
    ssoId,
    email,
    templateId,
    actorId
  );
  
  if (resp.ok) {
    console.log("Successfully generated SSO configuration link:");
    console.log(resp.data.adminSSOConfigurationLink);
  } else {
    console.log("Failed to generate SSO configuration link");
    console.log("Status Code: " + resp.code);
    console.log("Error: " + resp.error.errorMessage);
  }
} catch (error) {
  console.log("Failed to generate SSO configuration link: " + error);
}
# Args:
#   tenant_id (str): The ID of the tenant for which to generate the SSO configuration link.
tenant_id = "my-tenant-id"
#   expire_time (int, optional): Expiration duration in seconds. For a 6-hour link, use 21600.
expire_time = 21600  # 6 hours
#   email (str, optional): Email address associated with the admin.
email = "admin@example.com"
#   sso_id (str, optional): SSO identifier for the tenant.
sso_id = "my-sso-id"
#   actor_id (str, optional): When provided, this is recorded as the audit actor for actions
#     performed inside the SSO Setup Suite (instead of the temporary user). It is used as-is for
#     audit attribution and is not validated.
actor_id = "my-admin-actor-id"

try:
    link = descope_client.mgmt.tenant.generate_sso_configuration_link(
        tenant_id=tenant_id,
        expire_time=expire_time,
        email=email,
        sso_id=sso_id,
        actor_id=actor_id
    )
    print("Successfully generated SSO configuration link:")
    print(link)
except AuthException as error:
    print("Failed to generate SSO configuration link")
    print("Status Code: " + str(error.status_code))
    print("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  tenantID (string): The ID of the tenant for which to generate the SSO configuration link.
tenantID := "my-tenant-id"
//  expireDuration (int64): Expiration duration in seconds. For a 6-hour link, use 21600.
expireDuration := int64(21600) // 6 hours
//  ssoID (string): SSO identifier for the tenant (optional, can be empty string).
ssoID := "my-sso-id"
//  email (string): Email address associated with the admin (optional, can be empty string).
email := "admin@example.com"
//  templateID (string): Template ID to use for the configuration page (optional, can be empty string).
templateID := ""
//  actorID (string): Optional (pass "" for none). When provided, this id is recorded as the audit
//    actor for actions performed inside the SSO Setup Suite (instead of the temporary user). It is
//    used as-is for audit attribution and is not validated.
actorID := "my-admin-actor-id"

link, err := descopeClient.Management.Tenant().GenerateSSOConfigurationLink(
    ctx,
    tenantID,
    expireDuration,
    ssoID,
    email,
    templateID,
    actorID,
)
if err != nil {
    fmt.Println("Failed to generate SSO configuration link: ", err)
} else {
    fmt.Println("Successfully generated SSO configuration link: ", link)
}
// Import required classes
import com.descope.model.tenant.request.GenerateTenantLinkRequest;

TenantService ts = descopeClient.getManagementServices().getTenantService();
// Args:
//   tenantId (String): The ID of the tenant for which to generate the SSO configuration link.
String tenantId = "my-tenant-id";
//   expireDuration (long): Expiration duration in seconds. For a 6-hour link, use 21600.
long expireDuration = 21600; // 6 hours
//   ssoId (String): SSO identifier for the tenant (optional).
String ssoId = "my-sso-id";
//   email (String): Email address associated with the admin (optional).
String email = "admin@example.com";
//   templateId (String): Template ID to use for the configuration page (optional).
String templateId = "";

try {
    GenerateTenantLinkRequest request = GenerateTenantLinkRequest.builder()
        .tenantId(tenantId)
        .expireDuration(expireDuration)
        .ssoId(ssoId)
        .email(email)
        .templateId(templateId)
        .build();

    String link = ts.generateSSOConfigurationLink(request);
    System.out.println("Successfully generated SSO configuration link: " + link);
} catch (DescopeException de) {
    System.out.println("Failed to generate SSO configuration link: " + de.getMessage());
}
// Args:
//   tenantID (string): The ID of the tenant for which to generate the SSO configuration link.
var tenantID = "my-tenant-id";
//   expireTime (string): Expiration duration in seconds. For a 6-hour link, use "21600".
var expireTime = "21600"; // 6 hours
//   ssoId (string, optional): SSO identifier for the tenant.
var ssoId = "my-sso-id";
//   email (string, optional): Email address associated with the admin.
var email = "admin@example.com";
//   templateId (string, optional): Template ID to use for the configuration page.
var templateId = "";

try
{
    var resp = await descopeClient.Mgmt.V1.Tenant.Adminlinks.Sso.Generate.PostAsync(new GenerateTenantAdminLinkRequest
    {
        TenantId = tenantID,
        ExpireTime = expireTime,
        SsoId = ssoId,
        Email = email,
        TemplateId = templateId,
    });

    var link = resp!.AdminSSOConfigurationLink;
}
catch (DescopeException ex)
{
    // Handle the error
}
Was this helpful?

On this page