I have a connected app, with canvas component in a visualforce page using <apex:canvasApp>
. Signed Request (POST) is enabled.
If I admin-approve users, the canvas app gets a valid Signed Request POSTed with auth_token and refresh_token, like expected.
The problem occurs if I choose user self-authorization:
I initiate the OAuth flow using Sfdc.canvas.oauth.login
and on the Callback URL, I use window.opener.Sfdc.canvas.oauth.childWindowUnloadNotification(window.location.hash)
to emit the result to the canvas.
This reloads the canvas page and I can then access the auth_token using Sfdc.canvas.oauth.token()
However, a call to Sfdc.canvas.client.refreshSignedRequest
leads to a respone Code 403 "userApprovalRequired"
with empty payload.
I can see in the background a http request made to https://eu3.salesforce.com/services/data/v36.0/platformconnect/signedrequest
, returning an encoded response. If I decode it using my client secret, it gives me a CanvasRequest with issuedAt = NULL and no auth_token or refresh_token
Also, calling Sfdc.canvas.client.repost({refresh : true})
does not lead to a POST on my canvas page, but again a GET request with _sfdc_canvas_authvalue = user_approval_required
Am I missing a step or doeing something wrong?