function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MikeGillMikeGill 

Oauth issue when trying cookbook recipe - blank page after granting access (PHP)

I am testing out oauth recipe using dotcloud.com (love the simplicity of this service and have used it for testing other stuff ok)

 

Here is what I am trying to setup and test:

http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php

 

After creating the files and push the code to dotcloud. Testing redirects me to sf login page where I can login, then grant access, after which I am redirected to blank page....

 

The url is this of the page is this

 

https://32468be0.dotcloud.com/oauth_callback.php?code=aPrxVyeZrusRBnfyxIlvdJRvh04y2Hlhz6jTOjs8wDq8H0G8ROEo96YfrsUYdUNnYhX.lF6bFQ%3D%3D

 

I'm not a PHP expert, after looking at oauth_callback.php source I believe it's missing some parameters.

 

    . "&redirect_uri=" . urlencode(REDIRECT_URI);

 . "&grant_type=authorization_code"
    . "&client_id=" . CLIENT_ID
    . "&client_secret=" . CLIENT_SECRET

 

Anyone experienced this?

 

I guess the next thing I will try will be running on a local webserver (e.g. my OSX), but would rather get working on the dotcloud service.

 

Pat PattersonPat Patterson

Hi Mike,

 

It shouldn't be missing parameters - the values for CLIENT_ID etc are set by require_once 'config.php';

 

Can you look in the logs at dotCloud, and see if there are any PHP errors there? If there is an error relating to an untrusted certificate, you could try putting

 

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

after the existing set of curl_setopt() calls in oauth_callback.php. This tells PHP's curl library to not attempt to verify the salesforce SSL certificate. This issue is due to curl not including a proper set of root CA certificates and is described in more detail at http://boards.developerforce.com/t5/REST-API-Integration/token-failed-with-status-0/m-p/245431#M287

 

Cheers,


Pat

MikeGillMikeGill

Thanks Pat for respose - I need to put some time aside to circle back to this one.

Pat PattersonPat Patterson

For what it's worth, I put the same code on PHPFog and it just worked: https://superpat.phpfogapp.com/forceapp/