FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login
    1. Home
    2. francis.ducharme 0
    F
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    francis.ducharme 0

    @francis.ducharme 0

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    francis.ducharme 0 Unfollow Follow

    Latest posts made by francis.ducharme 0

    • RE: Duplicating an application held in 'Tenant1' to 'Tenant2' stays in 'Tenant1'

      @mark-robustelli thanks. I've also tried by retrieving the template application and then changing some of its properties as such

      //Use same object for next request (creating application), assign new values
      appTemplate.jwtConfiguration.accessTokenKeyId = primaryDefaultJwtKeyId;
      appTemplate.jwtConfiguration.idTokenKeyId = secondaryDefaultJwtKeyId;
      appTemplate.tenantId = newTenant.id;
      appTemplate.name = `Portal (${env.toUpperCase()})`;
      appTemplate.oauthConfiguration.authorizedRedirectURLs = [
        `https://frontend.com/*`,
        `https://backend.com/api/auth/callback`
      ]
      delete appTemplate.id;
      delete appTemplate.oauthConfiguration.clientSecret;
      delete appTemplate.oauthConfiguration.clientId;
      
      //assign new ID to roles...
      appTemplate.roles.forEach(role => role.id = crypto.randomUUID());
      
      const newApplication = await fusionAuthService.createApplication(appTemplate);
      
      async createApplication(applicationRequest) {
      
          const client = new FusionAuthClient(
            this.apiKey,
            this.url,
            applicationRequest.tenantId
          );
          
          try {
            return (await client.createApplication(null, { application: applicationRequest})).response.application;
          }
          catch (err) {
            this.logError(err);
          }
        }
      
      

      While this works API and UI wise any user trying to authenticate will receive no successResponse from ExchangeRefreshTokenForAccessTokenAsync and I have no further details in errorReponse either.

      So maybe something else needs to be zapped/modified before using the appTemplate to create the clone ?

      posted in Q&A
      F
      francis.ducharme 0
    • Duplicating an application held in 'Tenant1' to 'Tenant2' stays in 'Tenant1'

      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.

      posted in Q&A
      F
      francis.ducharme 0