[Return the value of a token the request].

@param string $token

@return Token|null
496887
public function decodeToken($token)
    {
        try {
            $parser = new Parser();

            if (!$token = $parser->parse((string) $token)) {
                throw new Exception('Token inválido');
            }

            return $token;
        } catch (Exception $e) {
            abort(401, 'Favor efetuar o login novamente');
        }
    }
1016303
public function setToken($token = null)
    {
        if ( ! $token and $this->session->has('googleapi_token') )
        {
            $token = $this->session->get('googleapi_token');
        }

        return $this->client->setAccessToken($token);
    }
179240
public function offsetGet($token)
    {
        if (isset($this->idf[$token])) {
            return $this->idf[$token];
        } else {
            return $this->logD;
        }
    }
1360686
protected function parseToken($token)
    {
        [$id, $content] = $token;

        if ($id == T_INLINE_HTML) {
            foreach ($this->compilers as $type) {
                $content = $this->{"compile{$type}"}($content);
            }
        }

        return $content;
    }
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'];
		
	}
1311649
public static function forgeDtoFromToken($token) {
        $token = trim($token);
        if(empty($token)) {
            return null;
        }
	    $token = trim($token);
	    $token = StringHelper::removeDoubleSpace($token);
        $tokenSegments = explode(SPC, $token);
	    $countSegments = count($tokenSegments);
       
        $isValid = $countSegments == 1 || $countSegments == 2;
        if(!$isValid) {
            throw new InvalidArgumentException('Invalid token format');
        }
		$tokenDto = new TokenDto();
        if(count($tokenSegments) == 1) {
	        $tokenDto->type = null;
	        $tokenDto->token = $tokenSegments[0];
        } elseif(count($tokenSegments) == 2) {
	        $tokenDto->type = strtolower($tokenSegments[0]);
	        $tokenDto->token = $tokenSegments[1];
        }
        return $tokenDto;
    }
1148201
protected function parseToken($token)
    {
        list($id, $content) = $token;
        if ($id == T_INLINE_HTML) {
            $content = $this->renderShortcodes($content);
        }

        return $content;
    }
534849
public function withToken(Token $token)
    {
        $card = $this->with('token', $token);

        if (null !== $card->number) {
            $lastDigits = strlen($card->number) <= 4
                ? $card->number :
                substr($card->number, -4);
            $card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
        }

        $card->cvv = null;

        return $card;
    }
1334115
protected function decrypt($token)
    {
        // Decrypt the token if there is an Encrypter instance
        if ($this->encrypter instanceof Encrypter) {
            $token = $this->encrypter->decrypt($token);
        }
        
        // Return the unserialized token
        return @unserialize($token);
    }
456618
protected function getValidPasswordReset($token)
    {
        $passwordResets = $this->passwordResetData->listEntries(['token' => $token]);
        if (count($passwordResets) !== 1) {
            return null;
        }
        $passwordReset = $passwordResets[0];

        $createdAt = $passwordReset->get('created_at');
        if (strtotime($createdAt.' UTC') < time() - 2 * 24 * 60 * 60 || $passwordReset->get('reset')) {
            return null;
        }

        return $passwordReset;
    }
447705
public function decryptToken(string $token)
    {
        $tokenData = false;
        $encrypted = base64_decode($token);

        if ($encrypted) {
            $serialized = Security::decrypt($encrypted, Configure::read('Security.cryptKey'));
            $tokenData = unserialize($serialized);
        }

        return $tokenData;
    }
1145091
final public function getAuthenticationInfo($token)
    {
        // TODO: Retrieve Authentication Info from Cache
        $authInfo = $this->doGetAuthenticationInfo($token);
        if ($authInfo) {
            $this->_matchCredentials($token, $authInfo);
        }

        return $authInfo;

    }
3031
public function setToken($token = null)
    {
        if (isset($token)) {
            return $this->token = $token;
        }

        return $this->token = gplcart_string_encode(crypt(session_id(), $this->config->getKey()));
    }
895416
public function retrieveResetToken($token)
    {
        return $this->queryBuilder->from($this->getTokenTable())
            ->where('token', $token)
            ->first();
    }
142600
protected function parse($token)
    {
        $result = new \stdClass();
        $result->violations = [];
        $result->payload = null;
        $segments = explode('.', $token);

        if (count($segments) !== 2) {
            $result->violations[] = new \InvalidArgumentException('Wrong number of segments');

            return $result;
        }

        list($payloadBase64, $signature) = $segments;

        $sign = $this->sign;

        if ($signature !== $sign($payloadBase64)) {
            $result->violations[] = new \InvalidArgumentException('Signature verification failed');
        }

        $result->payload = json_decode($this->base64url->decode($payloadBase64));

        if (!($result->payload instanceof \stdClass)) {
            $result->violations[] = new \InvalidArgumentException('Invalid payload encoding');
        }

        return $result;
    }
953570
public function getUserIdFromToken(string $token): string
    {
        if (!$this->isTokenValid($token)) {
            throw new \InvalidArgumentException('This token is invalid');
        }
        $tokenData = $this->decryptToken($token);

        return $tokenData['user_id'];
    }
1058163
protected function getValue(Token $token, $value = null)
    {
        $value = $value ?: $token->match['value'];
        $type  = $token->match['type'];

        switch (true) {
            case $type === 'int':
                return (int) $value;
            case $type === 'char' &&
                 preg_match('(^(?P<value>-?\\d+)%2F100$)', $value, $match):
                return $match['value'] / 100;
            case $type === 'char':
                return (string) urldecode($value);
            default:
                throw new \RuntimeException(
                    "Unknown value type $type in line {$token->line} at position {$token->position}."
                );
        }
    }