How to get the access_token to call the Apex REST service from outside using the Rest Client

How to get the access_token to call the Apex REST service from outside using the Rest Client ?

I have a connected App and that gives me

Consumer Secret : 1180XXXXXXXXXX

Consumer Key  : MVG9d8..z.hXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

enter image description here

When I used below URL, I got the error:

https://ap5.salesforce.com/services/oauth2/token?client_id="3MVG9d8..z.hDcPJZPIzGJ5UZDuKCOqbHXXXXXXXXXXXXXXXXXXXXX"&
client_secret="11805XXXXXXXXXX"&username="UserName"&password="Password-SecurityToken"&grant_type=password

when I used below, I see the error, why ???

enter image description here

Whats wrong I used with username and password ??
Why its saying invalid client id ?

Yes I tried with below as well

https://ap5.salesforce.com/services/oauth2/token?client_id="3MVG9d8..z.hDcPJZPIzGJ5UZDuKCOqbH8CCGCPnmwQuRbwLZ_2f.thbqWMX82H7JRGx4
6VYyEkuwzQ9._ww5"&client_secret="1180508865211885204"&username="pXXXXXXXXXXXXXXX.com"&password="AgXXXXXXXX"&grant_type=password

Here I put my actual username and password which I used to login into the Production salesforce org. Please guide.

::::::UPDATED POST::::

Now this is final URL:’ Still it says

https://ap5.salesforce.com/services/oauth2/token?client_id="3MVG9d8..z.hDcPJZPIzGJ5UZDuKCOqbH8CCGCPnmwQuRbwLZ_2f.thbqWM
    X82H7JRGx46VYyEkuwzQ9._ww5"&client_secret="1180508865211885204"&username="<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="32426a6a6a6a6a6a6a6a724a4b1c515d5f">[email protected]</a>"&
    password="<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e5a4b5d5a474049434b6e1f1e1e1e74175f785e575a4b43461d7f19457e437b1d5e626b746866">[email protected]</a>"&grant_type=password

enter image description here

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Did you add your username and password with a security token to the url variables that call for them? From your url it looks like you just have “Username” and “Password” where the variables should be.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x