Package Connected Apps in Second-Generation Managed Packaging
Add a connected app to a second-generation managed package.
Prerequisites: Create a connected app.
-
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.
- From your packaging org, upload the 1GP package to create a package version.
-
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.
- Navigate to the source for your connected app, or pull the source from the org where the connected app is being developed.
- Create a source .xml file in your 2GP directory and reference the connected app you want to include. See the Sample Source File section.
- 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.