I am using Enterprise WSDL for salesforce integration. Currently I am able to authenticate user with salesforce account and able to get the Refresh_Token & Access_Token successfully. Can any one please tell me how can I pass the Access_Token in request when I am using Web Service. Because in salesforce documentation they have specified only direct Login process but not the OAuth process.

  • you need to just access salesforce with soap or use aouth for an app third party app?
    – highfive
    Mar 6, 2014 at 9:36
  • Thanks for your reply. Like currently i am using direct login process with the below code string username = "************@gmail.com"; string password = "xz6isl77KwS4sO5Qhj"; int retryCount = 0; bool done = false; while (retryCount < 6) { binding = new SforceService(); binding.Timeout = 60000;LoginResult lr; try { lr = binding.login(username, password); }}} Now what should i do in this to make the authentication using AccessToken. Mar 6, 2014 at 9:39

1 Answer 1


Refer to this.
Do your binding.login(); call inside a try catch and check for any exceptions. Also I hope you have appended the security token at the end of the password in your
string password = "xz6isl77KwS4sO5Qhj";

  • It is currently in try catch block in my code and I am using password + security token. But the main question for me how can i use access_token in request instead of username & password because I want to OAuth 2. for accessing the access and refresh token. Mar 6, 2014 at 10:27
  • Check service URLs that are using in salesforce for integrations. This may help you. Below code segment is for call particular service in C#.NET. List<BasicNameValuePair> qsList = new ArrayList<BasicNameValuePair>(); qsList.add(new BasicNameValuePair("oauth_token", accessToken)); String queryString = URLEncodedUtils.format(qsList, HTTP.UTF_8); HttpGet userInfoRequest = new HttpGet(userIdEndpoint + "?" + queryString); HttpResponse userInfoResponse = client.execute(userInfoRequest);
    – highfive
    Mar 6, 2014 at 10:50
  • how can I add this text of code in my Apex WebService, Like they have there own classes and functions, so for making any request to salesforce we need to call the methods from SforceService. So how can I convert the request into SforceService variable. Like we need todo new SForceService().Create(new sObject[]{}); Mar 6, 2014 at 11:36
  • above code segment is not for use in Apex, but in C#.NET. Once you have logged in and got the access_token, then you need to setup an httpClient(userInforRequest above) and execute the relevent service URL with any query string parameters(which is here the access_token is one). Above code segment is to do that http call with query strings in C#
    – highfive
    Mar 7, 2014 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .