I am looking to create an app that would be distributed via AppExchange. So this would be a 2nd Generation managed app. I have created the following components:

  1. CustomApplication
  2. ConnectedApp
  3. Pages
  4. ApexPages
  5. Custom Tab
  6. List item

The ApexPage renders a Canvas application, which is our ConnectedApp. When we deploy this to an organization everything works as expected. However, since the ConnectedApp is packaged the consumer key and secret are generated at the organization, so to test the solution we have to get those values from the organization.

If we distribute this package it means that every installation will have their own set of keys and secrets, which won't work.


How do we use a Canvas ConnectedApp in a 2GP while still retaining one set of consumer keys and secrets?

Solutions tried

I removed the ConnectedApp from the package and instead created a ConnectedApp on the Dev Edition organization. Now the package doesn't work because the ApexPage can't locate the Canvas ConnectedApp inside the package.

  • Hi and welcome to SFSE. For completeness, could you please edit the question to include code snippet examples of how you are currently referencing the connected app in your apex pages?
    – Phil W
    Commented Sep 14, 2022 at 20:17

1 Answer 1


In general, you need to create a Connected App and put it into a released 1GP.

In your 2GP, your ConnectedApp metadata references the namespace, API name, and version of the Connected App you put in the released 1GP. The reason for this "hack" is because Connected App's have sensitive information such as the consumer key, secret and possibly certificates. This information should not be in your source code management system with the rest of your 2GP.

Before you add the Connected App to your 1GP and upload it, be sure to note the version of the Connected App.

The ConnectedApp metadata in the 2GP will usually be relatively sparse; however, since you have a Canvas App, your 2GP will have to specify the Canvas options because the 1GP will only contain your Connected App - not your Apex.

<?xml version="1.0" encoding="UTF-8"?>
<ConnectedApp xmlns="https://soap.sforce.com/2006/04/metadata">



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .