SalesForce-ServiceNow Integration

Madhurya M J
Tera Contributor

I am trying to implement Salesforce Spoke in ServiceNow to pull data from Salesforce. I am trying to setup the Spoke using Option 2 in order to implement bi-directional webhook as detailed in this documentation (https://docs.servicenow.com/bundle/washingtondc-integrate-applications/page/administer/integrationhu...). At Step: Create credential records for the Salesforce Spoke, when I click on "Get OAuth Token", I am getting the error as shown. I configured all the credentials properly including the Client ID and Client Secret. Any idea where the error could be ?

1 ACCEPTED SOLUTION

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Madhurya M J 

 

Please check password is correct / upper case / lower case. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

11 REPLIES 11

YES, I wanted to try using the same instance.

Amit Pandey
Kilo Sage

Hi @Madhurya M J 

 

Please try this-

 

        var client_id = '3MV******Zqm2';
        var client_secret = 'AE146*****D864B8D9E';
        var grant_type = 'client_credentials';
        var token_endpoint = 'https://your_instance.sandbox.my.salesforce.com/services/oauth2/token';
        var token_grant_url = token_endpoint + "?grant_type=" + grant_type + "&client_id=" + client_id + "&client_secret=" + client_secret;

        var token_request = new sn_ws.RESTMessageV2();
        token_request.setEndpoint(token_grant_url);
        token_request.setHttpMethod("post");

        var token_response = token_request.execute();
        var response_body = token_response.getBody();
        var response_obj = JSON.parse(response_body);
        var access_token = response_obj.access_token;

        gs.info('Token request response: ' + response_body);
        gs.info('Access token: ' + access_token);

 

Please mark my answer helpful and correct.

 

Regards,

Amit

Hello, Thanks for help, but where exactly should I use this code? I mean in which scripting option?

This is Business rule.

@Madhurya M J You can also opt for a no code solution to avoid needing to use code or script. Unito is entirely no-code and supports bidirectional sync between ServiceNow and Salesforce.