1

We have a 2GP with an Aura Component that contains a Canvas App. We followed the documentation from Salesforce and created a Connected App in a namespace packaging org and created a released 1GP containing only the Connected App. Our 2GP has ConnectedApp metadata pointing to it and an Apex class that implements Canvas.CanvasLifecycleHandler and the onRender() method in the 2GP executed. All of this worked great.

We want to remove the Full Access Oauth Scope from the original Connected App in the 1GP (only need API and Refresh).

We modified that Connected App to remove unnecessary OAuth Scopes, made a note of the version number then Uploaded a new released version of the 1GP. We then changed the 2GP's ConnectedApp metadata version from 1.0 to 2.0 (the version of the Connected App before the upload). Then we created a new 2GP package version.

This time, onRender() in the Canvas Lifecycle Class did not execute. From the last build, only one line in the project changed - the ConnectedApp metadata file's version number.

We have another org where there is a locally created Connected App with exactly the same settings as version 2.0 of the Connected App in the released 1GP and it works fine with the Canvas App.

Because the Canvas Lifecycle Class is in the 2GP (and not the 1GP), I think the properties of the version 2.0 Connected App in the 1GP are superseding the properties in the ConnectedApp metadata in the 2GP which looks like this (with some obfuscation)...

<?xml version="1.0" encoding="UTF-8" ?>
<ConnectedApp xmlns="https://soap.sforce.com/2006/04/metadata">
  <version>2.0</version>
  <developerName>myNS__ConnectedApp</developerName>
  <label>Connector for Salesforce</label>

  <canvasConfig>
    <accessMethod>Post</accessMethod>
    <canvasUrl>https://api.example.com</canvasUrl>
    <lifecycleClass>MyCanvasLifecycle</lifecycleClass>
    <locations>Aura</locations>
    <samlInitiationMethod>None</samlInitiationMethod>
  </canvasConfig>

</ConnectedApp>

There is no documentation that I could find on overriding properties of the Connected App in the 1GP with ConnectedApp metadata in the 2GP. I only know it worked for version 1.0 of the Connected App.

Anyone have any idea why this might be happening?

1 Answer 1

0

There is a regression in Salesforce causing this issue. If I create a dummy MyCanvasLifecycle (and associated unit test) and include it in the 1GP, then it works. This was not always the case.

Salesforce Support showed me an identical ticket from 2021 with the same workaround so they've known about this issue for years.

2
  • I would also start taking a look at the new External Client Apps, as they are intended specifically for use in 2GP to eventually replace Connected Apps help.salesforce.com/s/… Commented Apr 13 at 14:19
  • We're on a path to move away from Aura/Canvas to LWC. Once that's completed, then our only use for the Connected App would be making REST API calls from an external service and Change Data Capture. Commented Apr 24 at 15:22

You must log in to answer this question.

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