diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/src/OAuth2/Provider.php b/src/OAuth2/Provider.php index c28d266..57d1f26 100644 --- a/src/OAuth2/Provider.php +++ b/src/OAuth2/Provider.php @@ -194,8 +194,21 @@ public function access($code, $options = array()) { case 'GET': // Need to switch to Request library, but need to test it on one that works - $url .= '?'.http_build_query($params); - $response = file_get_contents($url); + $url .= '?'.http_build_query($params, '', '&'); + + // make request + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($ch); + + // handle error; error output + if(curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) { + curl_error($ch); + Throw new \Exception('Something went wrong with oAuth2 Provider: ' . $response); + } + + curl_close($ch); parse_str($response, $return); break; @@ -239,4 +252,4 @@ public function access($code, $options = array()) } -} \ No newline at end of file +}