Visual Builder

Get Involved. Join the Conversation.

Topic

    Vinod Kumar Kv
    Salesforce rest OAUTH2 call from VBCS
    Topic posted December 8, 2018 by Vinod Kumar KvBronze Medal: 1,250+ Points, tagged REST 
    359 Views, 39 Comments
    Title:
    Salesforce rest OAUTH2 call from VBCS
    Summary:
    Salesforce rest OAUTH2 call from VBCS
    Content:

    Hello,

    We are trying to access datat from salesforce using oauth2 rest API authentication using VBCS services. We have created a connected app in salesforce and it working fine in postman. Same oauth2 request is not working in VBCS. Detailed screenshots of POSTMAN and VBCS setup are attached below.

    Please let us know how to make sales force OAuth2 API call from VBCS.

    Thanks

    Version:
    Version: 18.4.1
    Image:

    Comment

    • JT Thomas

      Can you share the output of the console log or network tab so we can see what the request looks like?

      ~/jt

    • Vinod Kumar Kv

      Hello Thomas,

      Please find attached the console.log and network.har (can be opened in any text editor)

      Thanks

      • JT Thomas

        Can you show the log/network details for the call to the Salesforce OAuth server? We should make sure you are getting an access token back first. 

        ~/jt

    • Vinod Kumar Kv

      Hello Thomas,

      Please find attached Network.har

      Thanks

      network.har (133KB)
    • Vinod Kumar Kv

      Hello,

      Any update on Salesforce OAuth2 rest API implementation in VBCS because we have demo with he client. 

      Thanks

      • JT Thomas

        I had asked for more information. To ensure you setup you client credentials OAuth call correctly, I'd like to see the call to the Salesforce OAuth server in the log to see if you received back an OAuth token successfully. Can you find that call in the network tab and share the request/response details?

        ~/jt

    • Vinod Kumar Kv

      Hello Thomas,

      Thanks for your reply. 

      We have already gone through the twitter blog also.

      Can you please provide us steps to configure OAUTH2 call to salesforce server from VBCS in-case we have missed minor steps.

      Thanks

      • JT Thomas

        In order to make progress on this issue I need to know which flow you want to use for your OAuth calls. That will determine which Authentication Mechanism you should use.I cannot tell from your Postman screenshots because I cannot see the Headers to see if you are using username:password or clientid:secret. That is why I asked to the see the network call to the SF OAuth server to see if what the error was there. I suspect you are using the incorrect Authentication Mechanism but this additional information will help me determine that. 

        Thanks,

        ~/jt

    • Vinod Kumar Kv

      Hello Thomas

      Please find below the flow for OAuth calls made to salesforce:

      CALL 1 (To receive instance_url, token_type and access_token ):
      TYPE: POST
      URL:  https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=USER-CLIENT-ID&client_secret=USER-CLIENT-SECRET&username=USER-NAME&password=USER-PASSWORD-SALEASFORSE-TOKEN

       We need to pass username:password and clientid:secret  in the URL as shown in the above  CALL 1 URL 

      RESPONSE from CALL 1:
      {
          "access_token": "00D90000000npjw!AQcAQJIqLM7_PUP6ahbzFikmeWM4tY._t78FvLnthYyb6DjPUWrcHGhWHrUjBI3tA94W_3lRwZ.p55BQMBIQ5zUU_70zThgE",
          "instance_url": "https://nguleria-dev-ed.my.salesforce.com",
          "id": "https://login.salesforce.com/id/00D90000000npjwEAA/00590000001HuRnAAK",
          "token_type": "Bearer",
          "issued_at": "1545146633690",
          "signature": "gKI+aM5jQn6fjKYaD3Pvm71QqlwJo5+C2Xj92uCxL0g="
      }

      -------------------------------------------------------------------

      CALL 2 (To get data from salesforce):
      TYPE: GET
      URL: https://nguleria-dev-ed.my.salesforce.com/services/data/v43.0/query/?q=SELECT+name,email,MailingCity+from+Contact 
      REQUEST HEADER of CALL 2: Authorization Bearer 00D90000000npjw!AQcAQJIqLM7_PUP6ahbzFikmeWM4tY._t78FvLnthYyb6DjPUWrcHGhWHrUjBI3tA94W_3lRwZ.p55BQMBIQ5zUU_70zThgE
      instance_url, token_type and access_token received in call 1 will be input to call 2 to fetch data from salesforce using OAuth

      We need to put token_type and access_token as request header (as attribute - Authorization) in CALL 2 to fetch information from salesforce.

      RESPONSE from call 2:
      {
          "totalSize": 1,
          "done": true,
          "records": [
              {
                  "attributes": {
                      "type": "Contact",
                      "url": "/services/data/v43.0/sobjects/Contact/0039000002WwwLEAAZ"
                  },
                  "Name": "Naveen Guleria",
                  "Email": "naveen.guleria@gmail.com",
                  "MailingCity": "Bangalore"
              }
          ]
      }

      We are trying to use VBCS services for this but not able to make salesforce OAuth working.

      Please let us know if you require more information.

      Thanks

    • John Graves

      Vinod,

      This blog talks about using the Integration component of OIC to hook into SalesForce.  Would it be good to go through this and the SalesForce adapter?

      https://redthunder.blog/2017/03/10/teaching-how-to-integrate-salesforce-and-sales-cloud-with-oracle-integration-cloud-service/

      This would hide all this complexity from VBCS.

      -John

    • Vinod Kumar Kv

      Hello John,

      Thanks for your reply but it looks irrelevant in the present context as it refers to a totally different platform (OIC) and the tools available there are not supported by VBCS currently.

      We want to do the OAuth in VBCS using REST API not SOAP.

      Please let us know if you require more information from us on this issue.

      Thanks

      • John Graves

        Vinod,

        Sorry.  I had assumed you were using VBCS inside OIC, not stand-alone VBCS.  OIC Enterprise consists of VBCS, Integration Cloud and Process Cloud.

        Sorry for the confusion.

        -John

    • Vinod Kumar Kv

      Hello Shay,

       

      Can you please step in and support us on this, we are having this issue for a while now and not able to move forward.

    • Aparna Gaonkar

      Hi, your postman call shows you are using grant type = password and in VBCS you are using grant type = client credentials from your screeshot.  Please change the configuration in VBCS Service Connection to OAuth Resource Owner Password, and let us know.

    • Vinod Kumar Kv

      Hello,

      We have already tried  OAuth Resource Owner Password and screenshot you have seen is old one. We are getting the same error with  OAuth Resource Owner Password.

      It will be good if you could share VBCS - Salesforce integration checklist which will help us to move forward.

      Thanks

    • Aparna Gaonkar

      Vinod is it possible for you to get on a zoom with me and show the steps.  If yes, let me know I will send you a zoom invite

    • Mohana Gopal Selvam

      Hi Vinod,

      Any luck on this integration. We also tried to integrate same kind of 'token' authorization mechanism. 

      Thanks,

      Mohan

    • Aparna Gaonkar

      Hi Mohan, you can try the Resource Owner Password Grant.  Follow the SalesForce documentation in order to get the client id and client secret and token endpoint - something like https://login.salesforce.com/services/oauth2/token.  Should work.

    • Mohana Gopal Selvam

      Hi Aparna,

      I haven't tried to integrate SFDC. We have same kind of application to integrate. We are passing all arguments in the parameters to get the token. Once we get the token we are passing the token as bearer to post the data to the application. How to achieve this in VBCS?

      Thanks,

      Mohan