You need to sign in to do that
Don't have an account?
Santiago Taco
Web Server OAuth Authentication Flow "message": "Session expired or invalid", "errorCode": "INVALID_SESSION_ID"
Good Afternoon everyone,
I want to use Web Server OAuth Authentication Flow, I have done all this steps:
1. crete this URl to get de code id:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=3MVG9CEn_O3jvv0xJWqiGa511111rwY4GvEFzR44rfMsyb1vuI4AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&scope=refresh_token&redirect_uri=https://mail.google.com/mail/u/1/#inbox&display=popup
2. the code received was:
https://login.salesforce.com/services/oauth2/token?grant_type=authorization_code&code=aPrxPGj_8oB..iSmfoLZNHA50FFOit.PhfWwb_qJDfvIuXFYdePtZcyHDgqJJzwHIt8gxtlcFg%3D%3D&client_id=3MVG9CEn_O3jvv0xJWqiGa5BdlH1111GvEFzR44rfMsyb1vuI4AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&client_secret=30282611111123314693&redirect_uri=https://mail.google.com/mail/u/1/#inbox
3. Create this post url:
https://login.salesforce.com/services/oauth2/token?grant_type=authorization_code&code=aPrxPGj_8oB..iSmfoLZNHA50FFOit.PhfWwb_qJDfvIuXFYdePtZcyHDgqJJzwHIt8gxtlcFg%3D%3D&client_id=3MVG9CEn_O3jvv0xJWqiGa5BdlHKrwY4GvEFzR44rfMsyb11111AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&client_secret=3028261111123314693&redirect_uri=https://mail.google.com/mail/u/1/#inbox
4. I got this Json request:
{
"access_token": "00D6A000000v0i1!ARYAQLDVBzNOhAl3SjEkNbN5zXMsF6iQQPOqcVNXs_FIf_Qrjm2Ez42Lr6fQn5EnfPYWmNKewHwAToq0D.6apcnXUyFudTqF",
"refresh_token": "5Aep861w1PjQhFtnoCbFAb.Tb5OnHJATNq8AGpuzXOLx5VicJ3RmIKYO.MhC9HVgKCP02qo3QHd3AF5jKjq8JgV",
"signature": "ofNXb7vhw1uMmJ6eOJENeDaytzu/Hf/gmTq3z7FB0C8=",
"scope": "refresh_token",
"instance_url": "https://ioetexamples-dev-ed.my.salesforce.com",
"id": "https://login.salesforce.com/id/00D6A000000v0i1UAA/0056A000000VKGVQA4",
"token_type": "Bearer",
"issued_at": "1524418764934"
}
5. I tryied to use this Get method to obtain a List of Available Objects:
https://ioetexamples-dev-ed.my.salesforce.com/services/data/v20.0/sobjects/ -H "Authorization: Bearer 00D6A000000v0i1!ARYAQLDVBzNOhAl3SjEkNbN5zXMsF6iQQPOqcVNXs_FIf_Qrjm2Ez42Lr6fQn5EnfPYWmNKewHwAToq0D.6apcnXUyFudTqF" -H "X-PrettyPrint:1"
After that I got this message:
{
"message": "Session expired or invalid",
"errorCode": "INVALID_SESSION_ID"
}
What could be wrong?
I want to use Web Server OAuth Authentication Flow, I have done all this steps:
1. crete this URl to get de code id:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=3MVG9CEn_O3jvv0xJWqiGa511111rwY4GvEFzR44rfMsyb1vuI4AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&scope=refresh_token&redirect_uri=https://mail.google.com/mail/u/1/#inbox&display=popup
2. the code received was:
https://login.salesforce.com/services/oauth2/token?grant_type=authorization_code&code=aPrxPGj_8oB..iSmfoLZNHA50FFOit.PhfWwb_qJDfvIuXFYdePtZcyHDgqJJzwHIt8gxtlcFg%3D%3D&client_id=3MVG9CEn_O3jvv0xJWqiGa5BdlH1111GvEFzR44rfMsyb1vuI4AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&client_secret=30282611111123314693&redirect_uri=https://mail.google.com/mail/u/1/#inbox
3. Create this post url:
https://login.salesforce.com/services/oauth2/token?grant_type=authorization_code&code=aPrxPGj_8oB..iSmfoLZNHA50FFOit.PhfWwb_qJDfvIuXFYdePtZcyHDgqJJzwHIt8gxtlcFg%3D%3D&client_id=3MVG9CEn_O3jvv0xJWqiGa5BdlHKrwY4GvEFzR44rfMsyb11111AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&client_secret=3028261111123314693&redirect_uri=https://mail.google.com/mail/u/1/#inbox
4. I got this Json request:
{
"access_token": "00D6A000000v0i1!ARYAQLDVBzNOhAl3SjEkNbN5zXMsF6iQQPOqcVNXs_FIf_Qrjm2Ez42Lr6fQn5EnfPYWmNKewHwAToq0D.6apcnXUyFudTqF",
"refresh_token": "5Aep861w1PjQhFtnoCbFAb.Tb5OnHJATNq8AGpuzXOLx5VicJ3RmIKYO.MhC9HVgKCP02qo3QHd3AF5jKjq8JgV",
"signature": "ofNXb7vhw1uMmJ6eOJENeDaytzu/Hf/gmTq3z7FB0C8=",
"scope": "refresh_token",
"instance_url": "https://ioetexamples-dev-ed.my.salesforce.com",
"id": "https://login.salesforce.com/id/00D6A000000v0i1UAA/0056A000000VKGVQA4",
"token_type": "Bearer",
"issued_at": "1524418764934"
}
5. I tryied to use this Get method to obtain a List of Available Objects:
https://ioetexamples-dev-ed.my.salesforce.com/services/data/v20.0/sobjects/ -H "Authorization: Bearer 00D6A000000v0i1!ARYAQLDVBzNOhAl3SjEkNbN5zXMsF6iQQPOqcVNXs_FIf_Qrjm2Ez42Lr6fQn5EnfPYWmNKewHwAToq0D.6apcnXUyFudTqF" -H "X-PrettyPrint:1"
After that I got this message:
{
"message": "Session expired or invalid",
"errorCode": "INVALID_SESSION_ID"
}
What could be wrong?
I can't otherwise see an issue based on what you posted. I'm a little confused by what you're sending for #5. You used syntax for sending the header via "-H", but you didn't put "curl" in there. Try adding that, if you're not using it already. Also, try sending the header values first, or maybe without the PrettyPrint, just to see if you can get it to work at a bare minimum.
As per Salesforce documentation.
Access tokens have a limited lifetime specified by the session timeout in Salesforce. If an application uses an expired access token, a “Session expired or invalid” error is returned. If the application is using the Web server or user-agent OAuth authentication flows, a refresh token may be provided during authorization that can be used to get a new access token.
There is no way to know how long the access token will work. For each request you will have to first check if the session token is working or not. If the session is expired then refresh the access token using refresh token and use the updated token otherwise keep calling the web service.
Get Url
https://ioetexamples-dev-ed.my.salesforce.com/services/data/v20.0/query?q=SELECT+name+from+Account
Headers:
Authorization:
Bearer 00D6A000000v0i1!ARYAQDuI4Es3esUOagShRX49WC.12121212121212121sSATI8aVwE622h4FduppNqav2NdMaAqMx4mWUGKnwj
Content-Type:
application/json