1

I am working on an integration between a Portal written in Angular and a Salesforce Org.

To better test this during development I want to connect my local Angular code with my scratch org.

To receive data from SF we use Remote API and starting from Monday (after Winter release) we are having an issue with receiving responses from Salesforce.

To make the connection I authorize an org, make

sfdx force:org:display -u ${alias}

get token and url from this information and launch portal locally on port 4200. I use this information from the org to make requests to Salesforce:

 POST method to https://business-agility-7203-dev-ed.my.salesforce.com/apexremote 

Accept: 'application/json',
Content-Type: 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,

BODY action: "Controller" ctx: {csrf: "", vid: "0661", ns: "", ver: 48} csrf: "" ns: "" ver: 48 vid: "0661" method: "getCurrentUser" tid: 1 type: "rpc"

Salesforce response with that error

action: "Unknown"
data: ""
message: "Remoting request invalid for your session. Refresh the page and try again"
method: "Unknown"
ref: false
statusCode: 402
type: "exception"
vfDbg: true
vfTx: true
where: ""

I’ve tried to connect with other orgs, to use Postman and received the same error. We think that the possible problem can be connected with the CSRF token. But we don't know how to request CSRF Token or where I can get it to use in my request.

2
  • 2
    You should be implementing authentication via OAuth 2 from your external Web app, probably using Web server flow. What you are doing is an abuse of the authentication session created for the SFDX CLI tool. Commented Oct 25, 2022 at 21:37
  • 2
    This is really an X-Y Problem type of problem. You were using a mechanic in a way that was never meant to be used, and now it's broken. There's really not much support for that. If you wouldn't mind making an edit to tell us more about the architecture of this app, we could probably help you find a more sustainable solution. Commented Oct 25, 2022 at 23:38

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.