+ Start a Discussion
Vijay VattikondaVijay Vattikonda 

User-agent Oauth flow REST API INVALID_SESSION_ID Error

I am trying to use user-agent oauth flow for a REST API call but getting INVALID_SESSION_ID using curl after authenticating. Here are the steps I am following:
1. Make a call to salesforce login to get access token:
https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=<CONSUMER KEY>&redirect_uri=https://Mysamplesite/returnurl.html
I get the following in the return URL after logining in:
https://mysamplesite/returnurl.html#access_token=<ACCESS TOKEN>&instance_url=https%3A%2F%2Fna16.salesforce.com&id=https%3A%2F%2Flogin.salesforce.com%2Fid%2F00Dj0000001sdROEAY%2F005j000000BU6JbAAL&issued_at=1423448917611&signature=nDdwrOErs%2B0JAQf9F8bBisFbKIm%2F8OlxC%2Bz917fZRbk%3D&scope=api+web+full&token_type=Bearer
2. I am using the ACCESS_TOKEN in the REST API call using CURL:
curl https://na16.salesforce.com/services/data/v20.0/ -H 'Authorization: Bearer <access_token>'

Getting the following error message:

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
Am I missing something?
Vijay VattikondaVijay Vattikonda
When I tried the same sequence again today it seems to be working. Didn't change a thing! Does the developer account take time to be ready for API call?
Vadim EfimovVadim Efimov

Same issue here. An access token I get via https://www.salesforce.com/us/developer/docs/api_rest/Content/intro_understanding_user_agent_oauth_flow.htm doesn't work (REST API calls result in INVALID_SESSION_ID), while another access token I get via https://www.salesforce.com/us/developer/docs/api_rest/Content/intro_understanding_refresh_token_oauth.htm works like a charm.