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

  • 5
    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! – Matt Lacey Feb 6 '13 at 22:08
  • Deleted the troubleshooting discussion and posted the solution as an answer. – metadaddy Feb 6 '13 at 23:39
  • 5
    @LaceySnr The propagation delay across the login service has been the cause of much swearing! – metadaddy Feb 6 '13 at 23:41
  • 1
    @metadaddy it has, I've seen the threads to back that up. – ehime Feb 6 '13 at 23:43

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 Force.com 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);

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 :|

  • Mind adding an example of what a uri could be and how that differs from what a url is? Half of what I'm finding on google says they are the same. – TheGrimmScientist May 6 '17 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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