Get a Social User instance from a known access token and secret.

@param  string  $token
@param  string  $secret
@return \Laravel\Socialite\One\User
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,
        ]);
    }
938410
public function getAccessToken(string $token, string $verifier):AccessToken{
		$request = $this->requestFactory
			->createRequest('POST', Psr7\merge_query($this->accessTokenURL, ['oauth_verifier' => $verifier]))
			->withHeader('Accept-Encoding', 'identity')
		;

		$request = $this->getRequestAuthorization($request, $this->storage->getAccessToken($this->serviceName));

		return $this->parseTokenResponse($this->http->sendRequest($request));
	}
1339712
public function withToken(Token $token)
    {
        $this->grant = 'provided_token';
        $this->token = new AccessToken([
            'access_token' => $token->jwt(),
            'expires' => $token->expires()->timestamp,
        ]);

        return $this;
    }
633169
public function setToken($key, $secret = null)
    {
        $key = AnConfig::unbox($key);

        if (is_array($key)) {
            extract($key, EXTR_OVERWRITE);
        }

        $this->_token = null;

        if ($key) {
            $this->_token = new OAuthToken($key, $secret);
        }

        return $this;
    }
380498
public static function encrypt_secret($secret)
    {
        global $CFG;
        if ( startsWith($secret,'AES::') ) return $secret;
        $encr = AesCtr::encrypt($secret, $CFG->cookiesecret, 256) ;
        return 'AES::'.$encr;
    }
1141646
public static function decode($input, $secret = null) {
        // no input?
        if(!$input)
            return false;

        // decode
        $decoded = self::base64decode($input);
        if(!$decoded)
            return false;

        // output
        return self::xor($decoded, self::secret($secret));
    }
410699
public static function csrfTokenGenerate($secret, $user, $timeValidUntil = null)
    {
        if ($timeValidUntil === null) {
            $timeValidUntil = time() + 86400;
        }
        $hashedSecret = hash('sha512', $secret);
        $dataToHash = sprintf('%s-%s-%s', $hashedSecret, $user, $timeValidUntil);
        $hashedData = static::hashFunction($dataToHash);

        return sprintf('%s-%s', $timeValidUntil, $hashedData);
    }
864045
public static function fromToken(TokenInterface $token)
    {
        $user = $token->getUser();

        if ($user instanceof UserInterface) {
            return self::fromAccount($user);
        }

        return new self((string) $user, is_object($user) ? ClassUtils::getRealClass($user) : ClassUtils::getRealClass($token));
    }
1373854
public function userFromToken(string $token)
    {
        $user = $this->mapUserToObject($this->getUserByToken($token));
        return $user->setToken($token);
    }
228625
public static function create(?string $secret = null, int $period = 30, string $digest = 'sha1', int $digits = 6, int $epoch = 0): self
    {
        return new self($secret, $period, $digest, $digits, $epoch);
    }
985098
private function createDefaultUser(SamlSpResponseToken $token)
    {
        $result = null;
        if ($this->usernameMapper) {
            $result = $this->usernameMapper->getUsername($token->getResponse());
        }
        if (!$result) {
            $result = 'Anon.';
        }

        return $result;
    }
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'];
		
	}
38130
public static function decode(string $data, string $secret )
  {
    # Make a HASH of the secret
    $secret = openssl_digest($secret,'sha256');

    $b64 = static::base64url_decode($data);
    $ewt = json_decode($b64,true);

    $payload = openssl_decrypt($ewt['p'], $ewt['a'], $secret, 0, $ewt['i']);

    # Verify signature - if fail return null
    if ( strcasecmp(static::sign($payload,$secret,$ewt['h']),$ewt['s'])!=0) {
      return null;
    }

    return $payload;
  }
1255228
public static function parser(string $token, string $secret): Parse
    {
        $jwt = new Jwt($token, $secret);

        return new Parse($jwt, new Validate(), new Encode());
    }
1026354
public function consumer($url, $key, $secret)
    {
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string')
            //argument 2 must be a string
            ->test(2, 'string')
            //argument 3 must be a string
            ->test(3, 'string');
            
        return Consumer::i($url, $key, $secret);
    }
968531
private function retrieveByToken(string $token)
    {
        $token = $this->validateToken($token);
        if (!$token) {
            return NULL;
        }
        $user = new User();
        if ($token->hasClaim('sub')) {
            $user->id = $token->getClaim('sub');
        }
        if ($token->hasClaim('name')) {
            $user->name = $token->getClaim('name');
        }
        if ($token->hasClaim('email')) {
            $user->email = $token->getClaim('email');
        }
        if ($token->hasClaim('roles')) {
            $user->roles = explode(' ', $token->getClaim('roles'));
        }
        if ($token->hasClaim('registries')) {
            $user->registries = explode(' ', $token->getClaim('registries'));
        }
        if ($token->hasClaim('cpf')) {
            $user->cpf = $token->getClaim('cpf');
        }
        if ($token->hasClaim('avatar')) {
            $user->avatar = $token->getClaim('avatar');
        }

        return $user;
    }
225684
public function getByAccessToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('access_token', '=', $token)->first());
	}