Skip to content

Commit

Permalink
Specify $authorizationHeaderMethods also for PATCH, PUT and DELETE to…
Browse files Browse the repository at this point in the history
… fix issues with WP oAuth1.0a plugin.
  • Loading branch information
drsdre committed Jun 2, 2017
1 parent 3163e73 commit 61d3808
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions OAuth1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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)
*/
Expand All @@ -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';
}
}

0 comments on commit 61d3808

Please sign in to comment.