Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #47 from rhmvandelisdonk/master
Browse files Browse the repository at this point in the history
Add check to ratelimit on requestAccessToken call.
  • Loading branch information
hansott authored Dec 6, 2019
2 parents 3df6d0b + 42e49f1 commit 513e0ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Pinterest/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Pinterest\Api\Exceptions\TooManyScopesGiven;
use Pinterest\Api\Exceptions\AtLeastOneScopeNeeded;
use Pinterest\Api\Exceptions\InvalidScopeException;
use Pinterest\Http\Exceptions\RateLimitedReached;

/**
* This class is responsible for authenticating requests.
Expand Down Expand Up @@ -199,6 +200,7 @@ private function assertValidScopes(array $scopes)
* @return string The OAuth access token.
*
* @throws TokenMissing
* @throws RateLimitedReached
*/
public function requestAccessToken($code)
{
Expand All @@ -215,6 +217,10 @@ public function requestAccessToken($code)

$response = $this->http->execute($request);

if ($response->rateLimited()) {
throw new RateLimitedReached($response);
}

if (
!isset($response->body)
|| !isset($response->body->access_token)
Expand Down

0 comments on commit 513e0ef

Please sign in to comment.