function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chris Wong 16Chris Wong 16 

invalid client id when attempting OAuth Authentication with Username-Password Flow

Hi, I am new to Salesforce, so thanks for any help

I am trying to connect my application to the Salesforce REST API. I have a Ruby app so I am using Restforce (https://github.com/restforce/restforce). I'm attempting to use the Username/Password authentication which I believe is the same as the Session ID Authorization described here https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm

I created a new Connected Appin the Salesforce Setup App Manager. I clicked enable OAuth settings and selected Full Access as the Oauth scope. 

But when attempting the authentication I am receiving an error:

{"error":"invalid_client_id","error_description":"client identifier invalid"}

I’m using my personal salesforce account’s username, password and security token. I am using the Connected App's Consumer Key as the Client ID and Consumer Secret as the Client Secret

This happens both when using Restforce or when manually calling curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" ...

I'm pretty sure I'm copying/pasting the correct value of Consumer Key into Client ID.

Did I miss a step when setting up my Connected App? Could the error message mean something else?

Thank you for any help or suggestions!
Khan AnasKhan Anas (Salesforce Developers) 
Hi Chris,

Greetings to you!

Make sure you have white-listed salesforce IP: 
https://help.salesforce.com/articleView?id=000321501&type=1&mode=1 (https://help.salesforce.com/articleView?id=000321501&type=1&mode=1)

http://​​​​​​​http://www.salesforcegeneral.com/salesforce-articles/ip-whitelists-for-salesforce.html (http://http://www.salesforcegeneral.com/salesforce-articles/ip-whitelists-for-salesforce.html)

Please refer to the below links which might help you further with the above issue.

https://salesforce.stackexchange.com/questions/93007/oauth2-token-request-failing

https://developer.salesforce.com/forums/?id=906F00000009ABLIA2

https://salesforce.stackexchange.com/questions/179731/invalid-client-id

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Chris Wong 16Chris Wong 16
Hi Khan,

I am not practicing IP whitelisting from my network, so I do not think that is the issue.

I've looked into the other links and I don't think I have the same issues as them as I do not have the same mistakes with client_id vs clientId or having special characters in my password.

I will note that the Consumer Key has multiple periods (.) but that is consistent with what other users have pasted for their own consumer keys.

For the username/password I'm using my own personal credentials and I'm pasting screenshots of the oauth settings from my connected app that I created. Is there anything I need to do to connect my personal user to be able to do the Oauth authentication with the new connected app?

From the manage page:

User-added image

and the view page (blacked out consumer key just in case):

User-added image


Thank you for looking into it!
Elliott de Launay 4Elliott de Launay 4
I was having the same issue. I was not enforcing whitelisted IPs. By changing IP Relaxation to Relax IP restrictions allowed me to authenticate. 

App Manager -> Manage -> Edit Policies

User-added image
Jasmin JoshiJasmin Joshi
Thanks Elliott de Launay, I was also having same issue & the "Relax IP restrictions" policy change worked.
Tien Le 488Tien Le 488
my challenge was that I was using an old token.  Updated per suggestion (https://forum.uipath.com/t/salesforce-connection-issue/102154/12) and voila!! works!