/**
  * Returns whether or not the grant supports the client
  *
  * @param Client $client
  *
  * @return bool
  */
 public function supports(Client $client)
 {
     $isAllowed = in_array("refresh_token", $client->getAllowedGrantTypes());
     if (!$isAllowed) {
         return false;
     }
     $refreshToken = $this->getLatestRefreshToken($client);
     return $refreshToken !== null && !$refreshToken->isExpired();
 }
Esempio n. 2
0
 public function send(RequestInterface $request)
 {
     $request = $this->authenticationManager->authenticate($request, $this->client);
     $uri = (string) $request->getUri();
     if (strpos($uri, $this->client->getResourceUrl()) !== 0) {
         $uri = new Uri($this->client->getResourceUrl() . $uri);
     }
     $request = $request->withUri($uri);
     return $this->httpClient->send($request);
 }
 public function authorize(Client $client)
 {
     $authUrl = $client->getAuthUrl();
     header("Location: {$authUrl}");
     exit;
 }
 /**
  * @inheritdoc
  */
 public function supports(Client $client)
 {
     return in_array("client_credentials", $client->getAllowedGrantTypes());
 }