• allan31
  • NEWBIE
  • 15 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    Replies
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.  
I am stuck trying to obtain a token via the JWT Bearer Token Flow. I followed the steps here https://dreamevent.secure.force.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&type=5

1. Created the connected app and generated a JWT Bearer Token using the sample code provided by Salesforce

2. Authorised the app via the browser successfully with a POST request like the below

https://test.salesforce.com/services/oauth2/authorize?response_type=code&client_id=3MVG9KlmwBKoC7U3w7pS2H7mWZgOv7hyIA9Tj...90JmPpk&redirect_uri=https://test.salesforce.com/services/oauth2/success

3. Now trying to execute this from Postman using the below

https://test.salesforce.com/services/oauth2/token?assertion=e...ip5reUNICJbwa_tEDErguFZuSVjv8_eaO_wM6D9cM6ycAA73YBcw&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer

 I keep on receiving the error 
    "error": "invalid_grant",
    "error_description": "expired authorization code"

Anybody experienced this previously? I would be grateful for help on this

I am new to force.com and want to practice SOQL queries . how to do that. Any editor?