Connecting to grpc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const conn = new jsforce.Connection({ | |
loginUrl: "https://test.salesforce.com", | |
}); | |
const connectionResult = await conn.login(username, password); | |
const orgId = connectionResult.organizationId; | |
const metaCallback = (_params, callback) => { | |
const meta = new grpc.Metadata(); | |
meta.add("accesstoken", conn.accessToken); | |
meta.add("instanceurl", conn.instanceUrl); | |
meta.add("tenantid", orgId); | |
callback(null, meta); | |
}; | |
const callCreds = grpc.credentials.createFromMetadataGenerator(metaCallback); | |
const combCreds = grpc.credentials.combineChannelCredentials( | |
grpc.credentials.createSsl(root_cert), | |
callCreds | |
); | |
const client = new sfdcPackage.PubSub( | |
"api.pilot.pubsub.salesforce.com:7443", | |
combCreds | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment