8000 Merge branch 'Patches/oauthd-url-fix' into develop · oauth-io/sdk-php@0e7a54f · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e7a54f

Browse files
committed
Merge branch 'Patches/oauthd-url-fix' into develop
2 parents 45ce968 + b55e394 commit 0e7a54f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/OAuth_io/Injector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Injector {
88
public $session;
99
public $config = array(
1010
'oauthd_url' => 'https://oauth.io',
11+
'oauthd_base' => '/auth',
1112
'app_key' => '',
1213
'app_secret' => ''
1314
);

src/OAuth_io/OAuth.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ public function getOAuthdUrl() {
5151
*
5252
*
5353
*/
54-
public function setOAuthdUrl($url) {
54+
public function setOAuthdUrl($url, $base = '/auth') {
5555
$this->injector->config['oauthd_url'] = $url;
56+
if (strlen($base) > 1 && $base[0] != '/')
57+
$base = '/' . $base;
58+
if ($base == '/')
59+
$base = '';
60+
$this->injector->config['oauthd_base'] = $base;
5661
}
5762

5863
/**
@@ -99,7 +104,7 @@ public function refreshCredentials($credentials, $force = false) {
99104
$request = $this->injector->getRequest();
100105
$response = $request->make_request(array(
101106
'method' => 'POST',
102-
'url' => $this->injector->config['oauthd_url'] . '/auth/refresh_token/' . $credentials['provider'],
107+
'url' => $this->injector->config['oauthd_url'] . $this->injector->config['oauthd_base'] . '/refresh_token/' . $credentials['provider'],
103108
'body' => http_build_query(array(
104109
'token' => $credentials['refresh_token'],
105110
'key' => $this->injector->config['app_key'],
@@ -130,7 +135,7 @@ public function auth($provider, $options = array()) {
130135
$request = $this->injector->getRequest();
131136
$response = $request->make_request(array(
132137
'method' => 'POST',
133-
'url' => $this->injector->config['oauthd_url'] . '/auth/access_token',
138+
'url' => $this->injector->config['oauthd_url'] . $this->injector->config['oauthd_base'] . '/access_token',
134139
'body' => http_build_query(array(
135140
'code' => $options['code'],
136141
'key' => $this->injector->config['app_key'],

0 commit comments

Comments
 (0)
0