making callout from salesforce wth username and password code example
Example: how to supply username and password while making rest callouts in salesforce
String endpoint='https://xyz...com/';
String userID='xyz';
String password='pass';
String jsonBody ='userID=' + userID + '&password=' + password;
HTTP auth = new HTTP();
HTTPRequest r = new HTTPRequest();
r.setClientCertificateName('certificate_Name');
r.setEndpoint(endpoint);
r.setMethod('POST');
r.setBody(jsonBody);
r.setHeader('Content-Type','application/x-www-form-urlencoded');
HTTPResponse authresp=new HttpResponse();
authresp = auth.send(r);
system.debug(authresp);