function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
narwhal_narwhal_ 

Force.com Workbook REST Example Issue

As I am going thru the Force.com Workbook, I reach the REST API example. I am using cURL with the following cmd:

 

curl -s -H 'Authorization: OAuth token ...'

https://na15.salesforce.com/services/data/v29.0/analytics/reports/00Oi0000004tH4I

 

But I am getting "INVALID_SESSION_ID"

 

The tutorial doesnt cover authenticating. Any ideas?

narwhal_narwhal_

Thanks for your reply.

 

Is access token same as security token? As an example, if my security token is: abcd12345 -- i am using the following:

 

curl -s -H 'Authorization: OAuth abcd12345' https://na15.salesforce.com/services/data/v29.0/analytics/reports/reportIdHere

 

And i get back:

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

 

 

Ashish_SFDCAshish_SFDC

Hi, 

 

See the description and follow the instruction in the link below, 

 

Access Token

The access token is used by the client to make authenticated requests on behalf of the end user. It has a longer lifetime than the authorization code, typically on the order of minutes or hours. When the access token expires, attempts to use it will fail, and a new access token must be obtained via a refresh token.

In Force.com terms, the access token is effectively a SID or 'session', much like a session cookie on other systems, and should be protected against interception, for example by Transport Layer Security (TLS, aka SSL).

Note that if you want to use an OAuth token to access the Force.com Web UI on behalf of the user, either by setting a SID cookie or via the 'front door' URL (e.g. https://na1.salesforce.com/secur/frontdoor.jsp?sid=<sid_value>) you must include web in the list of requested scopes - see the discussion on the scope parameter in the web server flow section below.

 

Obtaining an Access Token in a Native Application (User-Agent Flow)

Client applications, for example, JavaScript running in the browser or native mobile or desktop apps, run on a user's computer or other device. Such apps are able to protect per-user secrets, but, since they are widely distributed, a common client secret would not be secure. The user-agent flow allows these applications to obtain an access token:

 

http://wiki.developerforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com

 

 

 

Harjeet Makkar 8Harjeet Makkar 8
Hi,

Im following the force.com workbook and reached the point where it talks about "Analytics REST API". so far book is great and they explained everything step by step and now im lost. They say go to "https://na1.salesforce.com/analytics/reports" and "https://na16.salesforce.com/services/data/v29.0/analytics/reports/" , mine is on na16. So i go there but it says invalid session id. 

In next step they are running Curl -s -H command with oAuth token. Where am i supposed to run this command and how do i get oAuth token. Im totally lost with this book , can anyone please help. Thanks

Regards,
Harjeet
Jonathan Vance 5Jonathan Vance 5
I am encountering this exact same issue. I have been following along in the Force.com Workbook, which explains everything clearly and completely until the REST API section on page 91. At that point, the Workbook stops explaining what to do. Does it mean to run curl -s -H from the command line? Do we need to supply our access token as a parameter? Where can I easily find my access token?

http://www.salesforce.com/us/developer/docs/workbook/forcecom_workbook.pdf
AshwaniAshwani
Simply write 

curl -s -H 'Authorization: Bearer<space><your_token>'