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
Abdur RaoofAbdur Raoof 

Unable to access APIs using CURL request

Hi All, I need to access APIs using CURL request but getting errors. Steps I did,
 
From my Trailhead account -->   Hands-On Orgs --> Any testing App ( My Trailhead Playground 1 )
Created a connected app with full access permissions
Fetched client id, client secret, username, password and security token
Then used in this bellow URL( first tried to get access token )
 
curl https://login.salesforce.com/services/oauth2/token -d 'grant_type=password&client_id=<CLIENT_ID>&client_secret=<client_secret>&username=abdurraoof@wise-koala-kluwgj.com&password=<PASSWORD><SecurityToken>' -H "X-PrettyPrint: 1"
Getting error
{ "error" : "invalid_grant", "error_description" : "authentication failure"}
I have followed many articles and Stackoverflow questions and videos but still facing this issue.
 
API access is allowed on new Trailhead account ? 
Any restriction of account types or something else??
 
Your support will be much appreciated, thanks in advance :)
 
Links I followed
https://www.cloudsciencelabs.com/blog/how-to-generate-an-access-token-to-access-salesforce-org
https://www.youtube.com/watch?v=dC1eo2W7Q7U
https://www.youtube.com/watch?v=-9pe0OQi7LA

Posted question
https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007LnbMhSAJ
HarshHarsh (Salesforce Developers) 
Hi Abdur,
I'd like you to please follow the following steps- to overcome this error.
  • Goto App Manager→  Connected App name→Manage→  Edit Policies to go to your Connected App’s Edit page
  • Under Permitted Users, select All users may self-authorize and hit save.
Then try It once.

Please mark it as Best Answer if the above information was helpful.

Thanks.

 
Abdur RaoofAbdur Raoof
Hi Harsh, I already it. But still getting same error.
Abdur RaoofAbdur Raoof

Abdur Raoof (Folio3)
Hi @all Finally its resolved.
We have to enable Allow OAuth Username-Password Flows 
From: Setup --> Quick find --> type: Identity --> OAuth and OpenID Connect Settings 
User-added image