Returns all current drafts for authenticated user.

@param TokenInterface $token

@return array
516544
public function getAllDrafts(TokenInterface $token)
    {
        $owner = UserSecurityIdentity::fromToken($token);
        $states = [Revision::STATE_ADDED, Revision::STATE_MODIFIED];

        $result = [];

        try {
            $result = $this->findBy([
                '_owner' => $owner,
                '_state' => $states,
            ]);
        } catch (ConversionException $e) {
            $result = [];
            foreach ($this->getAllDraftsUids($owner, $states) as $data) {
                try {
                    $result[] = $this->find($data['_uid']);
                } catch (ConversionException $e) {
                    $this->_em->getConnection()->executeUpdate(
                        'DELETE FROM revision WHERE uid = :uid',
                        ['uid' => $data['_uid']]
                    );
                }
            }
        } catch (MappingException $e) {
            $result = [];
            foreach ($this->getAllDraftsUids($owner, $states) as $data) {
                $draft = $this->find($data['_uid']);
                if (null !== $draft->getContent()) {
                    $result[] = $draft;
                } else {
                    $this->_em->getConnection()->executeUpdate(
                        'DELETE FROM revision WHERE uid = :uid',
                        ['uid' => $data['_uid']]
                    );
                }
            }
        }

        return $result;
    }
1027230
public function getStringRolesFromToken(TokenInterface $token)
    {
        $roles = array();

        foreach ($token->getRoles() as $role) {
            $roles[] = $role->getRole();
        }

        return $roles;
    }
128705
public function refreshAccessToken(TokenInterface $token)
    {
      $refreshToken = $token->getRefreshToken();

      if(empty($refreshToken))
        throw new MissingRefreshTokenException();

      $parameters = array(
        'grant_type'    => 'refresh_token',
        'type'          => 'web_server',
        'client_id'     => $this->credentials->getConsumerId(),
        'client_secret' => $this->credentials->getConsumerSecret(),
        'refresh_token' => $refreshToken,
      );

      require_once 'libx/base.php';

      require_once 'libx/net/http/codes.class.php';
      require_once 'libx/net/rest/client.class.php';
      require_once 'libx/net/rest/request.class.php';
      require_once 'libx/net/rest/response.class.php';

      $request = new \LibXRestRequest($this->getAccessTokenEndpoint(), \LibXRestRequest::REQUEST_METHOD_POST);
      $request->setParameters($parameters);

      $response = new \LibXRestResponse();

      $client = new \LibXRestClient();
      $client->execute($request, $response);

      // Parse token
      $token = $this->parseAccessToken($response->getData());

      // Store token
      $this->storage->storeAccessToken($this->service(), $token);

      // Return token
      return $token;
    }
1112041
public function findUserByValidRefreshToken($token)
    {
        /** @var BaseUser $user */
        $user = $this->findOneBy(['refreshToken' => $token]);

        if (!empty($user) && $user->isRefreshTokenValid()) {
            return $user;
        }

        return null;
    }
1123514
protected function getUserByToken($token) {
		$response = $this->getHttpClient()->request('GET', 'https://openapi.naver.com/v1/nid/getUserProfile.xml', [
			'headers' => [
				'Authorization' => 'Bearer ' . $token,
		    ],
		]);
		
		$xml = $response->getBody()->getContents();
		
		return $this->parseXML($xml)['response'];
		
	}
204076
public function streamsFollowed($token = null)
    {
        $token = $this->getToken($token);

        $usersAPI = new Users($token);

        return $usersAPI->streamsFollowed();
    }
1202130
public function sign(TokenInterface $token): string
    {
        $signer = $this->factory->create($token->algorithm());
        $key    = new Key($this->signKey->content(), $this->signKey->passphrase());

        return $signer->sign($token->payload(), $key);
    }
179240
public function offsetGet($token)
    {
        if (isset($this->idf[$token])) {
            return $this->idf[$token];
        } else {
            return $this->logD;
        }
    }
1145091
final public function getAuthenticationInfo($token)
    {
        // TODO: Retrieve Authentication Info from Cache
        $authInfo = $this->doGetAuthenticationInfo($token);
        if ($authInfo) {
            $this->_matchCredentials($token, $authInfo);
        }

        return $authInfo;

    }
812554
public function getTokenGuard(Token $token, $guards)
    {
        $providers = GuardChecker::getGuardsProviders($guards);

        // use only guard associated to access token provider
        return $providers->has($token->provider) ? [$providers->get($token->provider)] : [];
    }
1046736
protected function getCurrentUser()
    {
        if (!$this->tokenStorage) {
            return;
        }

        if (!$this->tokenStorage->getToken()) {
            return;
        }

        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof UserInterface) {
            return $user;
        }

        return;
    }
290805
public function vote(TokenInterface $token, $object, array $attributes)
    {
        if (!(($object instanceof Request) || $this->supportsAnyAttribute($attributes))) {
            return VoterInterface::ACCESS_ABSTAIN;
        }

        $requiredRole = $this->getRequiredRole($object);

        if (null === $requiredRole) {
            return VoterInterface::ACCESS_ABSTAIN;
        }

        $user = $token->getUser();

        if (!$user instanceof UserInformationInterface) {
            return VoterInterface::ACCESS_DENIED;
        }

        foreach ($user->getRoles() as $role) {
            if (strtoupper($role) == strtoupper($requiredRole)) {
                return VoterInterface::ACCESS_GRANTED;
            }
        }

        return VoterInterface::ACCESS_DENIED;
    }
201255
public function getTokenName($token)
    {
        return (isset($this->names[$token])
                ? $this->names[$token]
                : $token);
    }
1223256
private function getVariables(TokenInterface $token): array
    {
        $roles = $this->roleHierarchy ? $this->roleHierarchy->getReachableRoles($token->getRoles()) : $token->getRoles();

        return [
            'token' => $token,
            'user' => $token->getUser(),
            'roles' => array_map(function (Role $role) {
                return $role->getRole();
            }, $roles),
            'trust_resolver' => $this->authenticationTrustResolver,
            // needed for the is_granted expression function
            'auth_checker' => $this->authorizationChecker,
        ];
    }
1170521
public function retrieveByToken($identifier, $token)
	{
		$user = $this->conn->table($this->table)
			->where('id', $identifier)
			->where('remember_token', $token)
			->first();

		return $this->getGenericUser($user);
	}
222660
public function getAllowedMethods($token) {
        $token = (string)$token;
        $array = (isset($this->config['tokens'][$token]))?$this->config['tokens'][$token]:array();
        $allowed = array_merge_recursive(
            $this->config['tokens']['*'],
            $array
        );
        $allowed = array_change_key_case($allowed);
        array_walk_recursive($allowed,function(&$value,$key){$value=mb_strtolower($value);});
        return $allowed;
    }
505698
public function userFromTokenAndSecret($token, $secret)
    {
        $tokenCredentials = new TokenCredentials();

        $tokenCredentials->setIdentifier($token);
        $tokenCredentials->setSecret($secret);

        $user = $this->server->getUserDetails(
            $tokenCredentials, $this->shouldBypassCache($token, $secret)
        );

        $instance = (new User)->setRaw($user->extra)
            ->setToken($tokenCredentials->getIdentifier(), $tokenCredentials->getSecret());

        return $instance->map([
            'id' => $user->uid,
            'nickname' => $user->nickname,
            'name' => $user->name,
            'email' => $user->email,
            'avatar' => $user->imageUrl,
        ]);
    }