FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Duplicating an application held in 'Tenant1' to 'Tenant2' stays in 'Tenant1'

    Scheduled Pinned Locked Moved Unsolved
    Q&A
    1
    1
    3
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      francis.ducharme 0
      last edited by

      Hi,

      I'm trying to duplicate an application (TemplateApp) held in a tenant (TemplateTenant) using the 'sourceApplicationId' parameter but the clone always end up in the source tenant (TemplateTenant)

      Here's what I'm doing

      const newApplication = {};
      newApplication.name = 'Cloned app';
      newApplication.tenantId = newTenantResponse.id; //this is from a duplicated tenant, which works.
      
      //tenantTemplateId is the id of TemplateTenant
      const newApplicationResponse = await fusionAuthService.createApplication(tenantTemplateId, applicationTemplateId, newApplication);
      
      //Also trying to set the tenant in the patch call, no go.
      await fusionAuthService.updateApplication(newApplicationResponse.id, {
        oauthConfiguration: {
          authorizedRedirectURLs: [
            `https://www.website.com/*`,
            `https://backend.com/api/auth/callback`
          ]
        },
        tenantId: newTenantResponse.id
      });
      
      
      
      async createApplication(tenantTemplateId, sourceApplicationId, applicationRequest) {
      
          const client = new FusionAuthClient(
            this.apiKey,
            this.url,
            tenantTemplateId
          );
      
          try {
            return (await client.createApplication(null, { sourceApplicationId: sourceApplicationId, application: applicationRequest })).response.application;
          }
          catch (err) {
            this.logError(err);
          }
        }
      
        async updateApplication(applicationId, values) {
          try {
            await this.client.patchApplication(applicationId, { application: values });
          }
          catch (err) {
            this.logError(err);
          }
        }
      
      

      I'm not entirely sure about tenant scoping here. The client has to be initiated with the id of TemplateTenant, otherwise the call to createApplication fails saying the source application doesn't exist.

      Is that even possible?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post