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
Krati RajpurohitKrati Rajpurohit 

Getting "error":"invalid_client","error_description":"invalid client credentials" while trying to get auth code

Hey
 Getting "error":"invalid_client","error_description":"invalid client credentials" while trying to get auth code.
Done with the Permission setting and Ip address setting. Im able to generate auth code via curl call but not programatically.Please guide me

    private Client client = JerseyClientBuilder.newClient();
    private String clientId="3MVG9ZL0ppGP5UrBtzV375FzNEKv4M0YHXq47vVM8O3rYjXp1VkxmcTRA_mpzUYB6vtedwwGS.3AG6lsiIODA";
    private String redirecturi="https://localhost:8080/test/xypress-web/";
    
    private void makeAuthCodeRequest()  {
        String username="k**0009@gmail.com";
        String password="*******";
        String LoginInstance="'https://login.salesforce.com";
        
        String apiVersion ="";
        //String consumerKey="";
        String secretKey="*********";
        String granttype="password";
        
        String jsonString="";
        try {
        PostMethod post = new PostMethod("https://login.salesforce.com/services/oauth2/token");
        post.addParameter("grant_type",granttype);
            post.addParameter("client_id",clientId);
            post.addParameter("client_secret",secretKey);
            post.addParameter("username",username);
            post.addParameter("PASSWORD",password);
            post.addParameter("redirect_uri",redirecturi);
            HttpClient httpclient = new HttpClient();
            httpclient.executeMethod(post);
            String postResp = post.getResponseBodyAsString().toString();
           
        } catch (Exception e) {
            e.printStackTrace();
            
        }