Paid Feature
This is a paid feature. Email us to get a license key to start a SuperTokens subscription.
If you want to try this feature without contacting us, you can:
- Sign up for our managed service, and use this feature in our development environment for free; OR
- You can self host the SuperTokens core and run it with the in memory db, by not connecting it to a database when running it. All paid features are enabled for free when using the in memory db.
Listing all tenants and apps
#
List all tenants for an app- NodeJS
- GoLang
- Python
- cURL
Important
For other backend frameworks, you can follow our guide on how to spin up a separate server configured with the SuperTokens backend SDK to authenticate requests and issue session tokens.
import Multitenancy from "supertokens-node/recipe/multitenancy";
async function listAllTenants() {
let resp = await Multitenancy.listAllTenants();
let tenants = resp.tenants;
tenants.forEach(tenant => {
let coreConfig = tenant.coreConfig;
let isEmailPasswordLoginEnabled = tenant.emailPassword.enabled;
let isThirdPartyLoginEnabled = tenant.thirdParty.enabled;
let isPasswordlessLoginEnabled = tenant.passwordless.enabled;
let configuredThirdPartyProviders = tenant.thirdParty.providers;
});
}
import (
"fmt"
"github.com/supertokens/supertokens-golang/recipe/multitenancy"
)
func main() {
resp, err := multitenancy.ListAllTenants()
if err != nil {
// handle error
}
for i := 0; i < len(resp.OK.Tenants); i++ {
currTenant := resp.OK.Tenants[i]
coreConfig := currTenant.CoreConfig;
fmt.Println(coreConfig)
isEmailPasswordLoginEnabled := currTenant.EmailPassword.Enabled;
isThirdPartyLoginEnabled := currTenant.ThirdParty.Enabled;
isPasswordlessLoginEnabled := currTenant.Passwordless.Enabled;
configuredThirdPartyProviders := currTenant.ThirdParty.Providers;
if isEmailPasswordLoginEnabled {
// Tenant has email password login enabled
}
if isThirdPartyLoginEnabled {
// Tenant has third party login enabled
fmt.Println(configuredThirdPartyProviders)
}
if isPasswordlessLoginEnabled {
// Tenant has passwordless login enabled
}
}
}
- Asyncio
- Syncio
from supertokens_python.recipe.multitenancy.asyncio import list_all_tenants
async def some_func():
response = await list_all_tenants()
if response.status != "OK":
print("Handle error")
return
for tenant in response.tenants:
current_config = tenant.core_config
print(current_config)
is_email_password_enabled = tenant.emailpassword.enabled
is_third_party_enabled = tenant.third_party.enabled
is_passwordless_enabled = tenant.passwordless.enabled
configured_providers = tenant.third_party.providers
if is_email_password_enabled:
print("Email password is enabled")
if is_third_party_enabled:
print(configured_providers)
print("Third party is enabled")
if is_passwordless_enabled:
print("Passwordless is enabled")
from supertokens_python.recipe.multitenancy.syncio import list_all_tenants
response = list_all_tenants()
if response.status != "OK":
print("Handle error")
for tenant in response.tenants:
current_config = tenant.core_config
print(current_config)
is_email_password_enabled = tenant.emailpassword.enabled
is_third_party_enabled = tenant.third_party.enabled
is_passwordless_enabled = tenant.passwordless.enabled
configured_providers = tenant.third_party.providers
if is_email_password_enabled:
print("Email password is enabled")
if is_third_party_enabled:
print(configured_providers)
print("Third party is enabled")
if is_passwordless_enabled:
print("Passwordless is enabled")
- Single app setup
- Multi app setup
curl --location --request GET '/recipe/multitenancy/tenant/list' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
curl --location --request GET '/recipe/multitenancy/tenant/list' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"tenants": [{
"tenantId": "customer1",
"emailPassword": {
"enabled": true
},
"thirdParty": {
"enabled": true,
"providers": [...]
},
"passwordless": {
"enabled": true
},
"coreConfig": {...}
}]
}
#
List all apps in a SuperTokens coreThis can only be done via a cURL command. There is no helper function for this in our backend SDKs since our backend SDKs are per app anyway.
curl --location --request GET '/recipe/multitenancy/app/list' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"apps": [{
"appId": "app1",
"tenants": [{
"tenantId": "customer1",
"emailPassword": {
"enabled": true
},
"thirdParty": {
"enabled": true,
"providers": [...]
},
"passwordless": {
"enabled": true
},
"coreConfig": {...}
}]
}]
}