Skip to content

Commit

Permalink
Merge pull request #19 from bookboon/hotfix/fix-scope
Browse files Browse the repository at this point in the history
Fix constructor with scopes
  • Loading branch information
lkm authored Oct 16, 2018
2 parents 3354302 + 1009ebd commit 9a89504
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/Client/Oauth/BookboonProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BookboonProvider extends AbstractProvider
private $host = 'bookboon.com';
private $protocol = 'https';

protected $scopes;
protected $scope = ['basic'];

public function __construct(array $options = [], array $collaborators = [])
{
Expand Down Expand Up @@ -87,10 +87,14 @@ public function generateRandomState()
public function getAccessToken($grant, array $options = [])
{
if (!isset($options['scope'])) {
$options['scope'] = join($this->getScopeSeparator(), $this->scopes);
$options['scope'] = $this->scope;
}

return parent::getAccessToken($grant, $options); // TODO: Change the autogenerated stub
if (is_array($options['scope'])) {
$options['scope'] = join($this->getScopeSeparator(), $options['scope']);
}

return parent::getAccessToken($grant, $options);
}

/**
Expand All @@ -103,7 +107,7 @@ public function getAccessToken($grant, array $options = [])
*/
protected function getDefaultScopes()
{
return ['basic'];
return $this->scope;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Client/OauthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct($apiId, $apiSecret, Headers $headers, array $scopes,
$this->provider = new BookboonProvider([
'clientId' => $apiId,
'clientSecret' => $apiSecret,
'scopes' => $scopes,
'scope' => $scopes,
'redirectUri' => $redirectUri
]);

Expand Down Expand Up @@ -159,10 +159,6 @@ public function requestAccessToken(array $options = array(), $type = OauthGrants
throw new UsageException("This oauth flow requires a code");
}

if (null === $this->act) {
$options['act'] = $this->act;
}

try {
$this->accessToken = $provider->getAccessToken($type, $options);
}
Expand Down

0 comments on commit 9a89504

Please sign in to comment.