-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify $authorizationHeaderMethods also for PATCH, PUT and DELETE to…
… fix issues with WP oAuth1.0a plugin.
- Loading branch information
Showing
1 changed file
with
17 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,13 +26,13 @@ | |
* ] | ||
* ``` | ||
* | ||
* @see https://github.com/WP-API/OAuth1 | ||
* @see https://wordpress.org/plugins/rest-api-oauth1/ | ||
* @see https://github.com/WP-API/OAuth1 | ||
* @see https://wordpress.org/plugins/rest-api-oauth1/ | ||
* | ||
* @author Andre Schuurman <[email protected]> | ||
*/ | ||
class OAuth1 extends \yii\authclient\OAuth1 | ||
{ | ||
class OAuth1 extends \yii\authclient\OAuth1 { | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -58,6 +58,11 @@ class OAuth1 extends \yii\authclient\OAuth1 | |
*/ | ||
public $accessTokenMethod = 'POST'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $authorizationHeaderMethods = [ 'POST', 'PATCH', 'PUT', 'DELETE' ]; | ||
|
||
/** | ||
* var $apiBaseUrl is Wordpress site url (json slug is auto added) | ||
*/ | ||
|
@@ -70,35 +75,32 @@ public function __construct( array $config ) { | |
parent::__construct( $config ); | ||
|
||
// Add apiBaseUrl to auth, requestToken and accessToken URL's | ||
$this->authUrl = $this->apiBaseUrl.'/'.$this->authUrl; | ||
$this->requestTokenUrl = $this->apiBaseUrl.'/'.$this->requestTokenUrl; | ||
$this->accessTokenUrl = $this->apiBaseUrl.'/'.$this->accessTokenUrl; | ||
$this->authUrl = $this->apiBaseUrl . '/' . $this->authUrl; | ||
$this->requestTokenUrl = $this->apiBaseUrl . '/' . $this->requestTokenUrl; | ||
$this->accessTokenUrl = $this->apiBaseUrl . '/' . $this->accessTokenUrl; | ||
|
||
// Set apiBaseUrl to Wordpress Rest API base slug | ||
$this->apiBaseUrl = $this->apiBaseUrl.'/wp-json'; | ||
$this->apiBaseUrl = $this->apiBaseUrl . '/wp-json'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function initUserAttributes() | ||
{ | ||
return $this->api('account/verify_credentials.json', 'GET', $this->attributeParams); | ||
protected function initUserAttributes() { | ||
return $this->api( 'account/verify_credentials.json', 'GET', $this->attributeParams ); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultName() | ||
{ | ||
protected function defaultName() { | ||
return 'wordpress'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultTitle() | ||
{ | ||
protected function defaultTitle() { | ||
return 'Wordpress'; | ||
} | ||
} |