You need to sign in to do that
Don't have an account?
Trevor Daniel
oAuth Help c#.net
Hi,
I have been thrown in the deep end!
I have been asked to write an api which logs into salesforce, downloads a file, uploads it to an external server for video encoding and then re-uploads it to salesforce.
I have been unable to find any examples of how to use oAuth in c#.net.
Has anyone managed to find or willing to share any code examples please?
Any help would be greatly appreciated.
Thanks
Trev
Trev,
In the same position. Documentation is "bitty" to say the least and not very intuitive.
I can let you know what I've done, so far though still not achieved the objective of retrieving data. Here goes:
Set up a Domain (under Domain Management)
Set up a Managed Connected App. This will create an OAuth token
Under Profiles, Edit the System Administrator, which is the default user when you create your development environment.
After creating the Connected App, there should be a checkbox under Connected App Access.
Documentation I've read indicates the following:
Make an http request. to the appripriate url
Pass the OAuth token value
Receive the data
So with that in mind, the url would be the domain you created plus the following path example
url/services/data/api_version/chatter
Documentation indicates the current api version is 28.0 (other documentation examples indicate 23.0)
Add a Header Request. Documentation example indicates the following:
HttpGet getRequest = new httpGet(url)
getRequest.AddHeader("Authorization", "OAuth" + myToken);
I've translated this as the following for .net:
string uri = "https://eu2.salesforce.com/services/data/v28.0/chatter/users";
string uri = [your url];
var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Headers.Add("OAuth", "your oauth token");
webRequest.Method = "GET";
var webResponse = (HttpWebResponse)webRequest.GetResponse();
At this point I get "Unauthorized", so something is amiss.
Maybe someone more experienced reading this might add some insight.
I'd be interested to know how you get on.