OAuth2Client - curl - invalid POST #296

Closed
dewa1t opened this Issue Aug 20, 2014 · 1 comment

Projects

None yet

2 participants

@dewa1t
dewa1t commented Aug 20, 2014

In hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php:219 POST params are setted to curl request. They are passed as an array, and according to http://php.net//manual/ru/function.curl-setopt.php they should be passed as string.

Request, that gets access token via POST is failes.

The problem can be solved the next way:

diff --git a/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php b/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php
index b7f1aca..43ea183 100644
--- a/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php
+++ b/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php
@@ -216,7 +216,7 @@ class OAuth2Client

                if( $type == "POST" ){
                        curl_setopt($ch, CURLOPT_POST, 1);
-                       if($params) curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
+                       if($params) curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($params) );
                }

                $response = curl_exec($ch);

@StorytellerCZ
Contributor

@dewa1t can you please submit a PR with the fix so that the fix can be attributed to you? Thanks!

@StorytellerCZ StorytellerCZ added the 2.x label Dec 29, 2014
@StorytellerCZ StorytellerCZ added this to the 2.x milestone Dec 29, 2014
@StorytellerCZ StorytellerCZ added a commit that closed this issue Jan 3, 2015
@StorytellerCZ StorytellerCZ Fix #296
Fixes #296 and increments copyright year.
d69729f
@StorytellerCZ StorytellerCZ added a commit that referenced this issue Mar 26, 2015
@StorytellerCZ StorytellerCZ Reverting #296 89e9e61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment