Hello,
I just tried setting up a connector using the Google+ preset. It brought me to the permissions page, but then I got an error (below). It seems like the code parameter is in $_REQUEST, and https://accounts.google.com/o/oauth2/token is the correct endpoint URL, as best as I can tell from http://code.google.com/apis/accounts/docs/OAuth2.html#login. Any ideas? Thanks!
Exception: Failed to fetch data from url "https://accounts.google.com/o/oauth2/token" (HTTP response code 400 Missing required parameter: code): <HTML> <HEAD> <TITLE>Missing required parameter: code</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Missing required parameter: code</H1> <H2>Error 400</H2> </BODY> </HTML> .
#0 /var/aegir/platforms/drupal-7.10/sites/crm3.albatrossdemos.com/modules/contrib/oauthconnector/modules/oauth2/lib/DrupalOAuth2Client.inc(31): DrupalOAuth2Client->get('/o/oauth2/token', Array)
#1 /var/aegir/platforms/drupal-7.10/sites/crm3.albatrossdemos.com/modules/contrib/oauthconnector/modules/oauth2/oauth2_common.pages.inc(33): DrupalOAuth2Client->getAccessToken(NULL, Array)
#2 [internal function]: oauth2_common_page_authorized('5', '5')
#3 /var/aegir/platforms/drupal-7.10/includes/menu.inc(503): call_user_func_array('oauth2_common_p...', Array)
#4 /var/aegir/platforms/drupal-7.10/index.php(23): menu_execute_active_handler()
#5 {main}
$_REQUEST:
Array
(
[q] => oauth/authorized2/5
[code] => 4/bzeNjxgp_XvSU_mZzrcb7Y_Wzd2Y
[Drupal_tableDrag_showWeight] => 0
[__unam] => 8318de0-1312532519a-22190501-7871
[SESS8c6e3635689a758e735436f14a1ca0ea] => p7gtfsUSkHe9Z2yGkYg-08yvb-7bQfyBSZxdsFGNQAs
[OctopusNoCacheID] => NOCACHEBOND04702863b2136a3274c89c6291ac1f34
[has_js] => 1
[Drupal_toolbar_collapsed] => 0
)
REQUEST_URI:
/oauth/authorized2/5?code=4/bzeNjxgp_XvSU_mZzrcb7Y_Wzd2Y
Comments
Comment #1
frans commentedYep i did ;)
Do you have set a scope under 'OAuth Consumer Advanced Settings'?
I used https://www.googleapis.com/auth/userinfo.profile.
It says it is missing 'code', which is weird, because that is set directly form the GET param.
'code' => $_GET['code'],So, do you get a code back? You can find that in your apache log.
Comment #2
jlyon commentedYep, scope was set to https://www.googleapis.com/auth/userinfo.profile. The logs say that it's getting code back:
"GET /oauth/authorized2/5?code=4/RWFJrxyJSnospyUXp7VGX2cNobmQ HTTP/1.1"Comment #3
frans commentedWeird,
I cannot reproduce it. It has probably something todo with CURL in
modules/oauth2/lib/DrupalOAuth2Client.inc
you can try to comment out line 107:
You can also check what is in $params. Install devel.module and on line 107
Comment #4
jlyon commentedSo I think the problem was that http_build_query() was urlencoding the parameters, so that the &s separating each parameter was turning into &s. I changed the http_build_query() calls to drupal_http_build_query() on line 96 and 107 and that fixed it.
Thanks for your help. I'd be happy to create a patch if you would like.
FYI, I was trying on php cli (both 5.3 and 5.2), running on Barricuda Aegir Nginx servers.
Comment #5
jlyon commentedComment #7
jlyon commentedI installed this on another site and needed the same fix, so here's a patch
Comment #8
frans commentedFixed and tested.