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
rachdi zakariarachdi zakaria 

Authentication using java api to salesforce services

Hi everebody I'm new in this forum and I would like to know if there is a possibilité to authenticate to Salesforce services from a Java client using certificates
now im using the classic methode for authentification that's with a user and password .
Ravikant Saini 1Ravikant Saini 1
String endpoint = this.instanceType+'/services/oauth2/token?grant_type=password'+
	    				'&username='+EncodingUtil.urlEncode(username,'UTF-8')+
	    				'&password='+EncodingUtil.urlEncode(password,'UTF-8')+
					'&client_id='+ConsumerKey__c+
					'&client_secret='+ConsumerSecret__c;
         HttpRequest req = new HttpRequest();
          req.setEndpoint(endpoint);
          req.setMethod('POST');
          Http h = new Http();
          String resp;
          HttpResponse res;
          res= h.send(req);
          resp = res.getBody();
         Map<String,Object> params = (Map<String,Object>)JSON.deserializeUntyped(response);
        return (String)params.get('access_token');