Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been dealing with this mismatch for the last two days, and am at my wits end. We have a development server set up (accessible from the outside), and I am trying to get my OAuth token back from my callback uri. I have my callback set up in my app as just how it is in our environmental configs.

The Config

And here is our attempt to reach the service, and the json response...

The URI callback attemp

Am I doing something wrong? or is there some configuration option I forgot in our app?

Here's the Application setup...

App setup

share|improve this question
One thing to be wary of here is the values are cached for a short about of time too, which means if you're constantly changing it trying to work out what's wrong, you're probably shooting yourself in the foot. I've done it before, and more than once! – LaceySnr Feb 6 '13 at 22:08
Deleted the troubleshooting discussion and posted the solution as an answer. – metadaddy Feb 6 '13 at 23:39
@LaceySnr The propagation delay across the login service has been the cause of much swearing! – metadaddy Feb 6 '13 at 23:41
@metadaddy it has, I've seen the threads to back that up. – ehime Feb 6 '13 at 23:43
up vote 6 down vote accepted

It looks like the issue is in your call to retrieve the token. You should pass application/x-www-form-urlencoded data like so:


There is a PHP sample in the Cookbook; the relevant code is

$token_url = LOGIN_URI . "/services/oauth2/token";

$code = $_GET['code'];

if (!isset($code) || $code == "") {
    die("Error - code parameter missing from request!");

$params = "code=" . $code
    . "&grant_type=authorization_code"
    . "&client_id=" . CLIENT_ID
    . "&client_secret=" . CLIENT_SECRET
    . "&redirect_uri=" . urlencode(REDIRECT_URI);

$curl = curl_init($token_url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);

$json_response = curl_exec($curl);
share|improve this answer

I'd just like to bring it to peoples attention that it's


and not


It's given in the Chatter REST API documentation as the second incorrect one - I just spent a few hours on this issue :|

share|improve this answer
Filing a doc bug right now. Thanks! – metadaddy Mar 27 '14 at 15:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.