You need to sign in to do that
Don't have an account?
Session expired or invalid immediately after successful OAuth login
Hey everyone,
I'm working on an application, and I got the OAuth2 workflow working right away, but I've been struggling with making requests afterward.
I get the access_token and instance_url back, and when I make a call like this:
curl -v https://__instance_id__ (na7).salesforce.com/services/data/v20.0/ -H "Authorization: OAuth access_token_from_earlier"
the server responds with a 401 with the following body:
[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
I've scoured the forum for solutions already, and made sure that I have API access turned on, signed up for the REST API through the developer preview form, but am still having errors all over the place.
Any help would be greatly appreciated.
Thanks!
What's your access token look like? You should mess up at least one of the characters so you're not posting a usable access token here (wouldn't want anybody to steal your org).
here's my token (a few chars off, for reasons you've described):
00DA0000000A5PO%21AR8AQJ0zIVK9EAibIaE1JLvWI_RxGoI4CKot9Qkj0G5.u0GrrOnSdTA2qZUS9xsCVPrkGDKtIv3ZK1g0ReZiZI4m77o435SC
Looks like you escaped the ! sign into %21. Don't do that. Try replacing %21 with ! and send it again (you may have to escape the ! in your shell).
Still getting the same error with this curl call:
Can you PM me your actual token you're getting? I work for salesforce. I promise not to do anything bad. :)
the escaping and quoting will drive you nuts, IIRC, use single quotes and don't escape anything in the sid, or stick in an env variable and reference that (which is what i normally do)
I am still facing the same problem. I am using curl on windows. What could be the problem? Appreciate your help.
al
I figured out the problem. http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/integration/message-id/221/print-single-message/false/page/1 had the solution.
Note from Pat Patterson provided the solution I was looking for. The salesforce instance should be the instance_url you got along with access_token (something like na3.salesforce.com, not login.salesforce.com). Thanks Pat
al
0
down vote
I faced the similar issue. We passing ConsumerKey, ConsumerSecret, username and password.
It is working fine initially. after 3 months we faced the sessionid issue. We tried and spent around 1month to resolve it.
Solution for this issue:
Concatenate the security token with your existing password. Security token will be created for a user.
Sample: passwordsecuritytoken
we tried this option and worked successfully.
I was using the API to obtain a token, and I started getting the same error message after a while. I still haven't figured out what caused it, but I'm using a workaround for now.
I tried Aboorvaraja Ramar's solution, but that did not fix it for me.
I think there is some sort of redirect happening during the request during which the token is lost if you do not choose this option.
@alarch 2022 and your comment saved my bacon, thank you!!!
(Yes it was an issue with the way the SF Url changes; "lightning" exchanged for "my")
@ayisha begum, thanks!
It is crazy. It was working on an org where I have set up a custom domain, but when I switch to a new org where there is no custom domain it stopped working. I guess, the custom domain played a role in it. Happy to further discuss about this to completely understand the behavior
Here are some things you can try to resolve the issue:
Make sure that you are using the correct instance URL for your organization.
Check if the access token has expired by looking at its expiration time, and request a new token if necessary.
Make sure that the user who granted access to the app still has the necessary permissions, and that their security settings haven't changed.
Verify that the API access is still enabled for your organization, and that you have signed up for the REST API through the developer preview form.
Try refreshing the token or logging in again to see if that resolves the issue.
If none of these steps work, you may want to reach out to Salesforce Support for further assistance.
I am also facing the same issue and I solve that.
In your authorization section you have to add type= Bearer Token and In Token = add token number