You need to sign in to do that
Don't have an account?

Refresh token always returns "expired access/refresh token"
Hello
I'm working on an app in java (Android) and I'm trying to use a refresh token to obtain a new OAuth access token. I got the access token through the SalesForce Android toolkit, and this logs me in fine for the session, but when I use the refresh token to try to get a new access token, I get the following error:
{"error":"invalid_grant","error_description":"expired access/refresh token"}
My consumer key and secret both seem to be fine, because I get the appropriate errors when I alter them. Has anyone else been getting this error? Is it something to do with the URL encoding?
Here is the code I'm using:
HttpPost httppost = new HttpPost(
"https://login.salesforce.com/services/oauth2/token");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("grant_type", "refresh_token"));
nameValuePairs
.add(new BasicNameValuePair("client_id", OAUTH_CONSUMER_KEY));
nameValuePairs.add(new BasicNameValuePair("client_secret",
OAUTH_CONSUMER_SECRET));
nameValuePairs
.add(new BasicNameValuePair("refresh_token", REFRESH_TOKEN));
nameValuePairs.add(new BasicNameValuePair("format", "json"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(httppost);
HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);
I figured it out. The refresh token was provided to me URL encoded, so the last two characters, ==, were shown as %3D%3D. I'll have to decode the token before storing it.
All Answers
I figured it out. The refresh token was provided to me URL encoded, so the last two characters, ==, were shown as %3D%3D. I'll have to decode the token before storing it.
Can you elaborate what you changed to get this working? I am facing the same error in my case.