question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Streaming API connections using OAuth

See original GitHub issue

I’m unable to subscribe to topics using OAuth based connections unless I perform a query first.

The following code never gets a message:

var salesforceConnection = new jsforce.Connection({
    instanceUrl: salesforceInstanceUrl,
    oauth2: {
        clientId: salesforceClientId,
        clientSecret: salesforceClientSecret,
        loginUrl: salesforceLoginUrl
    },
    refreshToken: salesforceRefreshToken
});

salesforceConnection.streaming.topic('Topic').subscribe(function(message) {
    console.log(message);
});

The following is my workaround:

var salesforceConnection = new jsforce.Connection({
    instanceUrl: salesforceInstanceUrl,
    oauth2: {
        clientId: salesforceClientId,
        clientSecret: salesforceClientSecret,
        loginUrl: salesforceLoginUrl
    },
    refreshToken: salesforceRefreshToken
});

salesforceConnection.describe('Custom__c', function() {
    salesforceConnection.streaming.topic('Topic').subscribe(function(message) {
        console.log(message);
    });
});

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
swati410commented, Jan 13, 2018

@stomita I am facing the same issue . I am not able to get the events . Can we subscribe to topics and does jsforce refreshes its token automatically for streaming apis. @freshlogic is there any latest update on this ?

0reactions
bhuvaneswarycommented, May 4, 2020

@stomita @freshlogic Does auto-refresh and auto-reconnect of dropped streaming client connections are supported?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set Up Authorization with OAuth 2.0 - Salesforce Developers
Setting up OAuth 2.0 requires some configuration in the user interface and in other locations. If any of the steps are unfamiliar, you...
Read more >
OAuth 2.0 for Mobile & Desktop Apps - YouTube
OAuth 2.0 allows users to share specific data with an application while keeping their usernames, passwords, and other information private. For ...
Read more >
How to Secure APIs Using OAuth in API Connect - YouTube
See the basic working setup of OAuth provider API in API Connect. Download sample APIs and Postman collection: https://ibm.co/2u2OQ1VIn this ...
Read more >
Connecting to a streaming endpoint | Docs - Twitter Developer
Requests must use of HTTP Basic Authentication, constructed from a valid email address and password combination. Connecting. To connect to the Streaming API, ......
Read more >
Authenticate an IMAP, POP or SMTP connection using OAuth
Register your application · Get an access token · Authenticate connection requests · Use client credentials grant flow to authenticate IMAP and POP ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found