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
Kevin RidleyKevin Ridley 

Oauth Password flow from HTTP

SF beginner here.  Ive been setup with a sandbox to work in their lightning.force.com environment.  I'm trying to obtain an access token using a windows app via http.  First thing I did was create a connected app.  I have it setup for OAuth and saved the Consumer Key and Secret codes.  When I try to use the password flow to get an access token, I get an invalid_client_identifier.  I have checked the value and it's correct.  I'm thinking it must be some sort of permission issue.  Do I have to use an endpoint in my sandbox, or do I use the documented https://login.salesforce.com/services/oauth2/token ?  Any other thoughts?
Karuna S 8Karuna S 8
you can use the call back end point  in your connected app as https://login.salesforce.com/services/oauth2/callback. And also you have to give the access of this connected app to your user profile, Edit your assigned profile, and search for the connected app, enable the check box and save it, After that you should be able to login via oauth.
Kevin RidleyKevin Ridley
I changed the callback to https://login.salesforce.com/services/oauth2/callback, then went into my user account.  My profile was setup as system administrator, so I clicked that link and went into that profile.  I clicked on Edit and found my connected app, which was not checked.  I checked it and saved everything.  Tried running my windows client app again using the client key/secret from the connected app setup.  I used my id and password with a password grant and still got the invalid client id.  I also tried adding the client secret to the end of my password, which I saw in some documentation and it still didn't work.  For the token endpoint, I tried both https://login.salesforce.com/services/oauth2/token and https://testlogin.salesforce.com/services/oauth2/token.  I keep getting that same invalid_client_id with a 400 return.  Any other things I can try?  I feel like I'm close but missing something.
Kevin RidleyKevin Ridley
Any ideas???
Naren9Naren9
Hi Kevin,
You have mentioned that  "Trying for access token using a windows app via http". Windows app means?.
First you test with Postman whether you are able to connect or not.

Thanks,
Naren
Kevin RidleyKevin Ridley

Not sure why this is important, but it's a PowerBuilder app making http calls.  Last night I was able to retrieve the token, but I had to put all of the connect info (grant_type, client_id, client_secret, username and pw) in the query string of the token url.  I was hoping to not have to do this, so I could embed that info in the header or body, but I guess this isn't possible?

 

Anyway, my next task is uploading a file and associating it to an opportunity with a known GUID for the opportunity.  I'm going to look through the api documentation to see if I can find which api to use, but if anyone knows already, it might save me some effort.

Thanks,
Kevin