2

I am implementing salesforce in my ASP.Net application and currently I am able to have login process as Username & password but now I want to change it to OAuth authentication. So i am able to get my Refresh Token & Access Token. Can any one please help me in order to create the session ID using these Token. Like in Password login we are generating the session ID, So is the process same in OAuth authentication also. Kindly check the below code how i did the login with password authentication.

binding = new SforceService();
LoginResult lr;

lr = binding.login(username, password);
if (lr.passwordExpired)
{
done = false;
break;
}
String authEndPoint = binding.Url;
binding.Url = lr.serverUrl;
binding.SessionHeaderValue = new PartnerWSDL.SessionHeader();
binding.SessionHeaderValue.sessionId = lr.sessionId;
header = new PartnerWSDL.SessionHeader();
header.sessionId = lr.sessionId;

1 Answer 1

2

I believe this is what you're after. Your current code uses the SOAP API whether this example is based on the REST API. I'm sure you will be able to work something out and it might be even better to shift your whole integration based on REST. Personally I have only done SOAP integrations with .net apps due to not having the REST API functionality in salesforce back then. If I'm to do it again, I would definitely look into REST. Good luck!

6
  • currently I have did every thing in SOAP only and now its really very difficult to convert to REST. Do you know the OAuth authentication process using SOAP API. Commented Mar 27, 2014 at 9:48
  • Then here is your answer - blogs.developerforce.com/developer-relations/2011/03/… Commented Mar 27, 2014 at 9:50
  • Thanks for you reply. now I have received all the URL for Metadata, Sobject, partner, Enterprise so for making any request to salesforce does I need to use the url as these URL and session ID as access_token. right? Commented Mar 27, 2014 at 10:57
  • Once you got those values back you need to make an HTTP GET call to the endpoint url ('id' in this case) and put the 'access_token' as a SessionID parameter in your HTTP GET header - that will authenticate the user. Once that's done, then you can use the 'access_token' again to make other subsequent calls. Have a look at these links - salesforce.com/us/developer/docs/api/Content/… and techsahre.blogspot.com.au/2012/10/… (it's in PHP - you need to "translate" this in C#) Commented Mar 27, 2014 at 22:12
  • Thanks for your reply. Its working fine for me. May i know how can i find the version id from my first request becuase the URL that I got contact {version} so we need to replace it with version number and what is the expiration of these access_token, Commented Mar 28, 2014 at 4:05

You must log in to answer this question.

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