I am getting an access_token from Facebook in my JavaScript. My logged in user has a HVCP profile (nowadays, a communities user). I would now like to make REST API calls to my Salesforce instance with this oAuth token in the background.
Almost all examples / docs mention Salesforce as the IdP for oAuth. However, in this case, how do I send the oAuth to Salesforce and retrieve data?
When I try the following...
loader.open('POST','https://login.salesforce.com/services/oauth2/authorize'); loader.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
loader.setRequestHeader("Authorization", "OAuth " + myAccessToken); //myAccessToken is the FB generated oAuth tokenvar params = { grant_type : 'authorization_code', client_id : 'my client id', client_secret : 'my client secret', }; loader.send(params);
I get the following error..
[ERROR][TiHttpClient( 372)] (TiHttpClient-1) [2199,2199] HTTP Error (org.apache.http.client.HttpResponseException): Bad Request
[ERROR][TiHttpClient( 372)] org.apache.http.client.HttpResponseException: Bad Request
[ERROR][TiHttpClient( 372)] at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:252)
[ERROR][TiHttpClient( 372)] at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:211)
[ERROR][TiHttpClient( 372)] at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
[ERROR][TiHttpClient( 372)] at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
[ERROR][TiHttpClient( 372)] at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1271)
[ERROR][TiHttpClient( 372)] at java.lang.Thread.run(Thread.java:1019)
Any suggestions would be appreciated. Thanks!