I am trying to create a 2GP that includes an Aura component, which shows a canvas app using force:canvasApp
.
I have tested this Aura component by creating it in the developer console. I did this in the organisation where I have a connected app, which is referenced by its developer name. This approach works in the 1GP.
However, I am running into trouble while trying to achieve the same result in a 2GP. I have created a scratch org from my PBO (also my Dev Hub). Then I created a managed package in this scratch org. This all according to this workflow. The project has roughly the following structure:
config
| project-scratch-def.json
force-app/main/default
| aura
| CanvasApp
| App.cmp
| App.design
| App.svg
| AppController.js
| staticresources
| canvasStatic.js
| canvasStatic.resource-meta.xml
sfdx-project.json
The App.cmp
file references the Connected App like this:
<force:canvasApp applicationName="Some Name" developerName="<namespace>__<developername>" />
Where the namespace
is the namespace of the previously mentioned 1G package, and the developer name is the name of the Connected App in that package. The namespace of the 1G package is linked to my PBO (Dev Hub), thus the scratch org has the same namespace.
When I create a version for this package, it installs successfully, but when I load the page it reports this message:
Your browsing session has ended or is invalid. Please re-login to Salesforce.com again.
I have tried generating a password for the user account as suggested here, but that did not help. I found this article from SFDX Developer Guides, but I do not understand steps 4 and 6. Following these instructions actually caused different problems. I added the .xml file as suggested, after which creating the package version would give the following error:
: Installing an app (App Name) that has been deleted.
I also could not install the 1GP package into the scratch org, as they have the same namespace:
- Package(Package ID) Package and subscriber org namespace collision, Details: The installing package namespace and org namespace cannot be the same.
Can anybody tell me how to show a connected app using force:canvasApp
in a 2GP?