Ejemplo n.º 1
0
 public function onBeforeSend(Event $event)
 {
     if (!$this->token) {
         $this->token = $this->tokenStorage->fetch();
     }
     if (!$this->token || $this->token->isExpired()) {
         $this->token = $this->flow->getToken();
         $this->tokenStorage->store($this->token);
     }
     $request = $event['request'];
     $request->setHeader('Authorization', sprintf('Bearer %s', $this->token));
 }
Ejemplo n.º 2
0
 public function testIsExpiredIsNotExpired()
 {
     $token = new AccessToken('token', 'refresh', 2);
     sleep(1);
     $this->assertFalse($token->isExpired());
 }