Working
This commit is contained in:
Родитель
c7d947161c
Коммит
5ddd153e20
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"esversion": 6
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
let jsforce = require('jsforce');
|
||||
let conn = new jsforce.Connection({
|
||||
// you can change loginUrl to connect to sandbox or prerelease env.
|
||||
// loginUrl : 'https://test.salesforce.com'
|
||||
});
|
||||
|
||||
let username = 'api@dotnetbuild.com';
|
||||
let password = 'p4uPgFg7VaTMGzLT';
|
||||
let fullName = 'my_connected_app7';
|
||||
|
||||
conn.login(username, password, function (err, userInfo) {
|
||||
if (err) {
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
let metadata = [{
|
||||
contactEmail: 'wade.wegner@gmail.com',
|
||||
description: 'my connected app 7',
|
||||
fullName: fullName,
|
||||
label: 'ConnectedAppLabel7',
|
||||
oauthConfig: {
|
||||
callbackUrl: 'sfdx://success',
|
||||
consumerSecret: '3256A12TT',
|
||||
scopes: [
|
||||
'Basic',
|
||||
'Api',
|
||||
'Web',
|
||||
'Full',
|
||||
'RefreshToken'
|
||||
]
|
||||
}
|
||||
}];
|
||||
|
||||
conn.metadata.create('ConnectedApp', metadata, function (err, results) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
conn.metadata.read('ConnectedApp', fullName, function (err, metadata) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('consumer key: ' + metadata.oauthConfig.consumerKey);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "connected-app-nodejs",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"jsforce": "^1.7.1",
|
||||
"libxmljs": "^0.18.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
var http = require('http');
|
||||
var libxml = require("libxmljs");
|
||||
|
||||
var body =
|
||||
'<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' +
|
||||
' xmlns:cmd="http://soap.sforce.com/2006/04/metadata" ' +
|
||||
' xmlns:apex="http://soap.sforce.com/2006/08/apex">' +
|
||||
' <soapenv:Header>' +
|
||||
' <cmd:SessionHeader>' +
|
||||
' <cmd:sessionId>00DF00000008H5t!ARgAQONqPATVL3emKy5EaUdqjg.Fwd_RFBoik.SlwoP7XZVCq7Heqlj1sYfI9AAPJZPXOIJoCAaoK9NQaHxlmBZpv6hnx95M</cmd:sessionId>' +
|
||||
' </cmd:SessionHeader>' +
|
||||
' </soapenv:Header>' +
|
||||
' <soapenv:Body>' +
|
||||
' <create xmlns="http://soap.sforce.com/2006/04/metadata">' +
|
||||
' <metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ConnectedApp">' +
|
||||
' <contactEmail>wade.wegner@gmail.com</contactEmail>' +
|
||||
' <version>29.0</version>' +
|
||||
' <description>my connected app</description>' +
|
||||
' <label>myconnectedapp</label>' +
|
||||
' <oauthConfig>' +
|
||||
' <callbackUrl>sfdx://success</callbackUrl>' +
|
||||
' <consumerSecret>3256A12TT</consumerSecret>' +
|
||||
' <scopes>Api</scopes>' +
|
||||
' <scopes>Web</scopes>' +
|
||||
' <scopes>Full</scopes>' +
|
||||
' <scopes>RefreshToken</scopes>' +
|
||||
' </oauthConfig>' +
|
||||
' </metadata>' +
|
||||
' </create>' +
|
||||
' </soapenv:Body>' +
|
||||
'</soapenv:Envelope>';
|
||||
|
||||
var xmlDoc = libxml.parseXmlString(body, { noblanks: true });
|
||||
console.log(xmlDoc.toString());
|
||||
var xml = xmlDoc.toString();
|
||||
|
||||
// console.log(body);
|
||||
|
||||
var postRequest = {
|
||||
host: 'na42.salesforce.com',
|
||||
path: '/services/Soap/m/29.0/00DF00000008H5t',
|
||||
port: 443,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'text/xml',
|
||||
'SOAPAction': 'create'
|
||||
}
|
||||
};
|
||||
|
||||
var req = http.request( postRequest, function( res ) {
|
||||
|
||||
console.log( res.statusCode );
|
||||
var buffer = "";
|
||||
res.on( "data", function( data ) { buffer = buffer + data; } );
|
||||
res.on( "end", function( data ) { console.log( buffer ); } );
|
||||
|
||||
});
|
||||
|
||||
req.on('error', function(e) {
|
||||
console.log('problem with request: ' + e.message);
|
||||
});
|
||||
|
||||
req.write( xml );
|
||||
req.end();
|
Загрузка…
Ссылка в новой задаче