I am doing callout from one salesforce org to another saleforce org to get access token but i am getting this error {"error":"unsupported_grant_type","error_description":"grant type not supported"}
I tried using my domain url as well, didnt worked
In connected app i have following access Access and manage your data (api) Provide access to your data via the Web (web) Perform requests on your behalf at any time (refresh_token, offline_access) Allow access to your unique identifier (openid)
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setEndpoint('https://xxx.salesforce.com/services/oauth2/token');
String CLIENT_ID = 'xyz';
String CLIENT_SECRET = 'xyz';
req.setBody('grant_type=code' + '&client_id='+CLIENT_ID +
'&client_secret='+CLIENT_SECRET + '&redirect_uri=https://xxx.my.salesforce.com/');
Http http = new Http();
HTTPResponse response = http.send(req);
System.debug('Body ' + response.getBody());
System.debug('Status ' + response.getStatus());
System.debug('Status code ' + response.getStatusCode());
Please help. Thanks in advance.