Salesforce Security Token Required: How to Fix
A Salesforce "security token required" error means Salesforce did not recognize the network address your integration logs in from, so it wants an API security token added to the end of the password. The fix is to reset the token and append it correctly, or, better, to use a trusted IP range or OAuth so you don't need the token at all.
This post is for owners and developers whose WordPress plugin, form connector, Zapier-style automation or custom script suddenly stopped talking to Salesforce. You will get the exact steps to reset the token, the right way to attach it to your password, a quick test you can run, and the safer long-term options. There is also a table of the most common causes, so you can find yours fast.
What the error actually means
Salesforce is cautious about logins that come from outside the office or from a server it has never seen. When a login comes from an unknown IP address (the numeric address of the machine making the request), Salesforce asks for an extra proof: the security token.
The security token is a long, case-sensitive string of letters and numbers that Salesforce emails to the user. It is not a second password you type in a separate box. For most older integrations, you glue it onto the end of the password. Salesforce explains the token in its own help page, Reset Your Security Token.
You will usually see one of these messages:
LOGIN_MUST_USE_SECURITY_TOKENINVALID_LOGIN: Invalid username, password, security token; or user locked out.- A plugin message like "API security token required"
The second message is vague on purpose. Salesforce does not tell an attacker which part was wrong. That means a typo in the password, a stale token and a locked account all look the same from the outside.
Common causes at a glance
| Cause | What it looks like | Fix |
|---|---|---|
| Token was never added | Works from your laptop, fails from the server | Append the token to the password (see below) |
| Token is stale | Worked for months, then stopped after a password change | Reset the token and update the integration |
| Token pasted wrongly | Space, line break or wrong order | Use PASSWORD + TOKEN with nothing between them |
| Server IP changed | Your host moved you or uses shared IPs | Add the IP to trusted ranges, or switch to OAuth |
| Wrong login URL | Sandbox credentials sent to production | Use test.salesforce.com for sandboxes, or your My Domain URL |
| Account problem | Locked user, expired password, or API access off | Unlock the user, reset the password, enable API Enabled on the profile |
| Token emailed to the wrong place | You never received it | Check the email on the user record and your spam folder |
Step 1: Reset your API security token
Resetting is the usual first fix. It creates a brand new token and makes the old one stop working.
- Log in to Salesforce as the same user the integration uses. A token belongs to one user, so using your admin account will give you the wrong token.
- Click your profile picture, then Settings.
- In the left menu open My Personal Information, then Reset My Security Token. (In Setup you can also type "Reset My Security Token" in Quick Find.)
- Click Reset Security Token.
- Check the inbox of the email address on that user record. The new token arrives by email, often within a few minutes.
Two things catch people out:
- Changing or resetting the password also resets the token. If someone rotated the integration user's password, the old token is dead too.
- If you can't see the reset option, your org may use IP restrictions or a different login setup. Ask your Salesforce admin to check, or use the trusted IP or OAuth options below.
After a reset, update the token everywhere it is stored: the plugin settings, your automation tool, environment variables and any scripts. Missing one old copy is a classic way to keep the error alive.
Step 2: Append the token to the password correctly
The rule is simple: password first, token second, nothing in between.
If the password is MyPass123 and the token is AbCdEf1234GhIj, the value to send as the password is:
MyPass123AbCdEf1234GhIj
Check these details:
- No space, dash or line break between the two parts.
- The token is case-sensitive. Copy and paste it instead of retyping.
- Some tools have a separate "Security Token" field. If so, put only the token there and leave the password alone. Adding it in both places breaks the login.
- If your password contains symbols such as
&,+or%, make sure the tool encodes them. In a raw request, use URL encoding.
Test the login before blaming the plugin
If you are comfortable with a terminal, you can test the OAuth username-password flow with curl. Replace the placeholders with your own values. This needs a Connected App, covered in Step 4.
curl https://login.salesforce.com/services/oauth2/token \
-d "grant_type=password" \
-d "client_id=YOUR_CONSUMER_KEY" \
-d "client_secret=YOUR_CONSUMER_SECRET" \
--data-urlencode "username=integration@yourcompany.com" \
--data-urlencode "password=PASSWORDTOKEN"
For a sandbox, swap login.salesforce.com for test.salesforce.com. If you use a My Domain address, use that instead. A JSON reply with an access_token means your credentials are fine and the problem is in the plugin. An error reply means the credentials or the IP rules are the issue.
Don't paste real passwords into shared terminals or chat tools. They end up in shell history.
Step 3: Use trusted IP ranges instead of the token
If your integration always runs from a fixed IP address, you can tell Salesforce to trust it. Logins from a trusted range skip the token requirement. Salesforce documents this under Restrict Login IP Addresses.
To add a trusted range, an admin does this:
- Go to Setup, then search "Network Access" in Quick Find.
- Click New under Trusted IP Ranges.
- Enter the start and end IP address of your server.
- Save.
You can also set Login IP Ranges on the integration user's profile (Setup > Profiles > your profile > Login IP Ranges). That one is stricter: it blocks logins from anywhere else.
Keep these cautions in mind:
- Use the narrowest range possible. One server, one address. A wide range trusts every machine inside it.
- Avoid this on shared hosting or serverless platforms where your outgoing IP changes. The error will come back the day the address moves.
- Ask your host for a dedicated outbound IP if you need one.
Step 4: Move to OAuth (the better long-term fix)
OAuth is a standard way for one app to get permission to use another without handing over the user's password. Instead of password plus token, your integration uses keys and short-lived access tokens. Salesforce lists the options in its OAuth flows documentation.
Why switch:
- No password to rotate, so no surprise breakage when someone changes it.
- Access can be limited to what the integration needs.
- Salesforce discourages the username-password approach and has announced the retirement of the older SOAP
login()call. Check the current Salesforce release notes for dates that affect your API version.
For server-to-server connections, the usual choices are:
- JWT bearer flow. Your server signs a request with a private key. Good for scheduled jobs and back-end scripts.
- Client credentials flow. Uses a consumer key and secret and runs as a designated user. Simpler to set up.
- Web server (authorization code) flow. For apps where a person clicks "Connect to Salesforce" and approves access.
In outline, an admin creates a Connected App (Salesforce is moving new setups toward External Client Apps, and the steps are similar). They enable OAuth settings, choose the minimum scopes such as api, and pre-authorize the integration user. Then you give the consumer key to your plugin or script, and store the secret or private key safely.
If your plugin only supports username, password and token, check whether a newer version supports OAuth, or whether a different connector does.
Keep the token and keys out of harm's way
A security token plus a password is the full key to a Salesforce user's API access. Treat it like one:
- Create a dedicated integration user with only the permissions the integration needs, not an admin account.
- Store secrets in environment variables or a secrets manager, never in code in a public repository or in a theme file. The OWASP Secrets Management Cheat Sheet covers the basics.
- Reset the token if you think it leaked, or when a developer or agency leaves.
- Don't send tokens by email or chat. Use a password manager's share feature.
Wondering whether keys like these could be sitting somewhere exposed on your site? Our guide on whether your website is hackable walks through common weak spots, and the free website security check gives you a quick outside look at a domain you own.
Quick checklist
- [ ] Logged in as the integration user, not an admin
- [ ] Token reset after any password change
- [ ] New token saved in every place the old one was used
- [ ] Password and token joined with no spaces
- [ ] Correct login URL (production vs sandbox)
- [ ] API Enabled is on for the user's profile
- [ ] User is not locked and the password has not expired
- [ ] Plan made to move to OAuth or a narrow trusted IP
Key takeaways
- The error appears when Salesforce sees a login from an IP address it doesn't trust and no token was supplied.
- Reset the token from Settings > My Personal Information > Reset My Security Token, as the integration user, then update every copy.
- Send the password and token together as
PASSWORDTOKEN, with no spaces, unless your tool has a separate token field. - Trusted IP ranges work for fixed server addresses. Keep them as narrow as you can.
- OAuth is the sturdier fix, because it removes the password-and-token pairing entirely.
Where a human audit fits
Getting the integration working is only half the job. The other half is making sure the website around it doesn't leak the keys. A Bug Circuit Essential audit is a manual security test of one website by a real person, for $49 one-time, ending in a written report with every issue and how to fix it. It is a focused small-site audit, not a multi-week enterprise pentest or a compliance certification. Fixes are quoted separately, and only if you ask.
A real human security engineer audits your whole site by hand and sends a full report: every issue, its severity, and the exact fix. From $49, with a 14-day money-back guarantee.