Newer Version Available

This content describes an older version of this product. View Latest

Package Connected Apps in Second-Generation Managed Packaging

Add a connected app to a second-generation managed package.
Prerequisites: Create a connected app.
  1. Create a first-generation managed package (1GP) and add the connected app. It’s fine if the connected app is the only component in the package. Use the same namespace as the 2GP package for the 1GP package.

    Take note of the version number of the connected app; you’ll use this number later.

  2. From your packaging org, upload the 1GP package to create a package version.
  3. Promote the 1GP version to the released state.

    Promoting the 1GP version allows the connected app to be included in a second-generation managed package. You don’t need to install the 1GP version into an org.

  4. Navigate to the source for your connected app, or pull the source from the org where the connected app is being developed.
  5. Create a source .xml file in your 2GP directory and reference the connected app you want to include. See the Sample Source File section.
  6. Create a second-generation managed package and add in the source code for the connected app. Add the source code manually. You can’t use sf project retrieve start or the retrieve() Metadata API call to add the source code.

Sample Source File

1<ConnectedApp xmlns="http://soap.sforce.com/2006/04/metadata">
2    <developerName>db_0110_ns4__A_Connected_App</developerName>
3    <label>A Connected App</label>
4    <version>1.0</version>
5</ConnectedApp>

The developerName is the combination of your namespace (db_0110_ns4) and the name of your connected app (A_Connected_App).

The version specified in the source file is the version number of the connected app. Use decimal formatting when specifying the version number. The version number must match the version number of the connected app before it was added to the 1GP managed package.

When you add a connected app to a 1GP package, and upload the package, the version number of the connected app is auto incremented. For example, when version 4.0 of a connected app is added to a 1GP package, the package version increments the version number of the connected app from 4.0 to 5.0. When creating the source file for your 2GP package, specify the version number of the connected app before it was uploaded into a 1GP package, in this case, 4.0.

Note