You need to sign in to do that
Don't have an account?
OAuth 2.0 User-Agent Authentication Problem
Hi,
I'm using OAuth2.0 User-Agent Authentication flow to get the access & refresh tokens so that I can use the REST API over remote access.
Now, the problem is that I'm able to authorize successfully and recieve the tokens, but while using those tokens, I'm recieving a java.net.ConnectException: Connection refused error.
Following Steps I'm doing
1. Redirecting to
https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=......&redirect_uri=......&state=myState
2. Authorizing the app in salesforce and then receiving back the access token and refresh tokens in the hash of the redirect_uri as
http://localhost:4502/etc/cloudservices/salesforce/testing.html#access_token={my_access_token}&refresh_token={my_refresh_token}&instance_url=https%3A%2F%2Fap1.salesforce.com&id=https%3A%2F%2Flogin.salesforce.com%2Fid%2F00D90000000gscOEAQ%2F00590000000sdtJAAQ&issued_at=1351151192815&signature={my_signature_value}&state=myState
&scope=id+api+refresh_token
3. Now I'm using the REST API using the same access token by doing a POST to
https://ap1.salesforce.com/services/data/v20.0/sobjects/Lead/
with request headers
Content-Type: application/json
Authorization: OAuth {my_access_token}
I have not escaped the access token while sending the post as it needs to be done when using CURL. Is that needed when using HttpClient Java API also?
The response that I'm getting is "java.net.ConnectException: Connection refused error."
Can someone please let me know what I'm doing wrong or how I can debug it further ??
Thanks,
Agraj
PS: I'm getting the exact same error if I try OAuth Refresh Token Process also.
Sorry for the noise.
I was getting "invalid_grant" with "expired access/refresh token" while validating the customer secret using the Refresh Token Procedure but since it was secured transmission so all I was getting in Java was "Connection Refused" with no detailed error message.
I got to know the detailed error by Setting up SSL Proxy in Charles as described here. After that I was able to see the request parameters and response send to https://ap1.salesforce.com which was earlier not readable.
All Answers
This is probably a firewall problem, check with your local network admins.
Hi Simon,
Thanks for your reply. This is not working even when the firewall is off. So, I'm not sure if firewall is playing a part here. Also, the behavior of refusing connection is intermittent as once or twice it has been able to establish the connection and the same code has worked so its a bit confusing.
Is there any tooling in Salesforce that can help me debug it further ? Perhaps some logs that indicate what is happening at SF end?
Thanks,
Agraj
If you're not connecting, there's nothing to gather a log.
Sorry for the noise.
I was getting "invalid_grant" with "expired access/refresh token" while validating the customer secret using the Refresh Token Procedure but since it was secured transmission so all I was getting in Java was "Connection Refused" with no detailed error message.
I got to know the detailed error by Setting up SSL Proxy in Charles as described here. After that I was able to see the request parameters and response send to https://ap1.salesforce.com which was earlier not readable.