You need to sign in to do that
Don't have an account?
OAuth 2.0 and the REST API
I'm having a look at REST and logging in via OAuth 2.0 client side flow and running into problems making a web request once I'm authenticated.
I don't think it's the actual auth because it's working fine on an iPhone application (Using traditional SOAP API) and the refresh and access tokens I'm getting match when I do from that app if I use the same client key.
My code is this:
void LoggedIn(object o, LoginEventArgs e) { System.Diagnostics.Trace.WriteLine(e); string url = e.InstanceUrl + "/services/data/v20.0/sobjects/"; WebRequest request = WebRequest.Create(url); request.Headers.Add("Authorization:OAuth " + e.AccessToken); WebResponse response = request.GetResponse(); // 403 Error! }
Am I missing something?
Update:
I used the returned token via cUrl and got the following response:
[ { "message" : "Session expired or invalid", "errorCode" : "INVALID_SESSION_ID" }
This is weird, should I be setting up a session cookie instead of adding an Authorization header?
A quick update again, I am in error here due to my inexperience with .Net! If you get a 401 or 403 error, a web request will throw an exception and that exception contains a response. I took a look at the content of the response and found this: