簡體   English   中英

我是否需要安全令牌才能連接到 Salesforce API?

[英]Do I need security token to connect to Salesforce API?

我正在嘗試使用 JSForce 連接到 Salesforce SOAP API

const connection = new jsforce.Connection({
  loginUrl: "https://customdomain.my.salesforce.com",
});
await connection.login(username, password);

當我運行它時,我收到以下錯誤

Error: INVALID_LOGIN: Invalid username, password, security token; or user locked out.
    at /Users/juancaicedo/code/calm/salesforce-poc/node_modules/jsforce/lib/connection.js:1552:13
    at tryCallOne (/Users/juancaicedo/code/calm/salesforce-poc/node_modules/promise/lib/core.js:37:12)
    at /Users/juancaicedo/code/calm/salesforce-poc/node_modules/promise/lib/core.js:123:15
    at flush (/Users/juancaicedo/code/calm/salesforce-poc/node_modules/asap/raw.js:50:29)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)
(Use `node --trace-warnings ...` to show where the warning was created)

這是一種很好的身份驗證方式,還是我應該做其他事情? 我在其他地方看到過提到安全令牌,這是首選嗎?

筆記

我可以使用這些憑據成功登錄 Salesforce UI ✅

I would be open to using another Node.js library, but do need to use the SOAP API (using the REST API would not be sufficient).

一些 Salesforce 組織也要求傳遞安全令牌。 您可能會找到您的令牌並嘗試在您的 API 調用中傳遞它。

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_concepts_security。

如果您在 salesforce 中使用jsforce ,在這種情況下,您可以使用以下代碼段直接獲取連接 object:

var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}' });

如果你想從外部系統連接,你可以 go 使用以下任何一種方式:

  • 使用訪問令牌和實例 URL
  • 使用用戶名和密碼

根據您各自的庫指定鍵。

注意:如果您遵循用戶名和密碼流程,在這種情況下,您必須在密碼末尾添加一個安全令牌 append 才能成功驗證。 您可以通過轉到您的用戶 salesforce 設置來獲取該安全令牌。

對於節點 JS,您可以參考此 package: https://www.npmjs.com/package/node-salesforce

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM