
Hi, Please see example below
As a common practice, if your question is answered, please choose 1 best answer. But you can give every answer a thumb up if that answer is helpful to you.Thanks,AlexString clientId = '*************************************************************************************************;
String clientSecret = '*********************';
String username = '****@*****.*****';
String password = '**************';
String token = '**************************************';
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://login.salesforce.com/services/oauth2/token');
req.setBody('grant_type=password' +
'&client_id=' + clientId +
'&client_secret=' + clientSecret +
'&username=' + EncodingUtil.urlEncode(username, 'UTF-8') +
'&password=' + EncodingUtil.urlEncode(password, 'UTF-8'));
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug('BODY: '+res.getBody());
System.debug('STATUS: '+res.getStatus());
System.debug('STATUS_CODE: '+res.getStatusCode());
System.debug('CONTENT_TYPE: '+res.getHeader('Content-Type'));
1 Antwort