Sunday, March 11, 2012

Getting Salesforce Data from External App

Salesforce encourages developers to authenticate using OAuth.

However, if you are creating a windows service to get data from SF, you'll need to choose the username/password flow.
https://ap1.salesforce.com/help/doc/en/remoteaccess_oauth_username_password_flow.htm

The Steps include:
1) Add new application via Setup -> Develop -> Remote Access
Under this method, the callback URL will not be used.

2) Perform a POST request
To get the authentication token:


https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9lKcPoNINVBIPJjdw1J9LLM82Hn
FVVX19KY1uA5mu0QqEWhqKpoW3svG3XHrXDiCQjK1mdgAvhCscA9GE&client_secret=1955279925675241571&username=username@salesforceInstance.com&password=SFpassword

3) Parse return JSON and get access_token

{"id":"https://login.salesforce.com/id/00Dx0000000BV7z/005x00000012Q9P",
"issued_at":"1278448832702","instance_url":"https://na1.salesforce.com",
"signature":"0CmxinZir53Yex7nE0TD+zMpvIWYGb/bdJh6XfOH6EQ=","access_token":
"00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW1
9ye6PE3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs"}

4) Perform a GET request

https://ap1.salesforce.com/services/data/v20.0/sobjects/Account/0019000000B8JxR?fields=AccountNumber,BillingPostalCode

User-Agent: Fiddler
Authorization: OAuth  access_token
Host: ap1.salesforce.com

2 comments:

  1. Salesforce is the best company that offers the efficient CRM service to the every entrepreneur in this world. Thanks for your content too. I would like to come back to this blog again in future.

    Salesforce Training in Chennai | Salesforce course in chennai

    ReplyDelete
  2. Cloud computing is a technology in which the future Information technology is going to rely on for their entire process. This is a technology that is not going to disappear just like that or the craze for this will also never reduce(). Your worth able content is also insisting the same. Thanks for sharing this in here.

    cloud computing training in chennai | cloud computing training

    ReplyDelete