@param string $clientId
@param string $clientSecret
@param string $username
@param string $password

@throws \Http\Client\Exception

@return Token
517910
public function authenticatePassword($clientId, string $clientSecret, string $username, string $password): Token
    {
        $request = new Request('POST', $this->tokenUrl, [
            'Content-Type' => 'application/json',
        ], json_encode([
            'client_id' => $clientId,
            'client_secret' => $clientSecret,
            'username' => $username,
            'password' => $password,
            'grant_type' => 'password',
        ]));

        $response = $this->getClient()->sendRequest($request);
        $responseBody = $response->getBody()->getContents();
        $this->token = $this->denormalizeObject(Token::class, [json_decode($responseBody)], false);

        return $this->token;
    }
788754
public function login($username = null, $password = null)
    {
        $this->_username = null !== $username ? $username : $this->_username;
        $this->_password = null !== $password ? $password : $this->_password;

        if (null === $this->_ssh_resource) {
            throw new TransportException(sprintf('None SSH connection available.'));
        }

        if (null === $this->_ssh_key_pub) {
            if (false === ssh2_auth_password($this->_ssh_resource, $this->_username, $this->_password)) {
                throw new TransportException(sprintf('Could not authenticate with username %s.', $this->_username));
            }
        } else {
            if (false === ssh2_auth_pubkey_file($this->_ssh_resource, $this->_username, $this->_ssh_key_pub, $this->_ssh_key_priv, $this->_ssh_key_pass)) {
                throw new TransportException(sprintf('Could not authenticate with keyfile %s.', $this->_keyfile));
            }
        }

        if (false === $this->_sftp_resource = ssh2_sftp($this->_ssh_resource)) {
            throw new TransportException("Could not initialize SFTP subsystem.");
        }

        return $this;
    }
739134
public function login($username, $password, $data)
    {
        // Verify the password against the stored hash
        if (!password_verify($password, $this->getStoredPassword($username))) {
            throw new \Exception('Incorrect username or password', 401);
        }

        // Create token
        return $this->app->tokens->create($data);
    }
1004058
function login($username, $password = '')
    {
        if (!parent::login($username, $password)) {
            return false;
        }

        $this->window_size_client_to_server[NET_SFTP_CHANNEL] = $this->window_size;

        $packet = pack('CNa*N3',
            NET_SSH2_MSG_CHANNEL_OPEN, strlen('session'), 'session', NET_SFTP_CHANNEL, $this->window_size, 0x4000);

        if (!$this->_send_binary_packet($packet)) {
            return false;
        }

        $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_OPEN;

        $response = $this->_get_channel_packet(NET_SFTP_CHANNEL);
        if ($response === false) {
            return false;
        }

        $packet = pack('CNNa*CNa*',
            NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SFTP_CHANNEL], strlen('subsystem'), 'subsystem', 1, strlen('sftp'), 'sftp');
        if (!$this->_send_binary_packet($packet)) {
            return false;
        }

        $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST;

        $response = $this->_get_channel_packet(NET_SFTP_CHANNEL);
        if ($response === false) {
            return false;
        }

        $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_DATA;

        if (!$this->_send_sftp_packet(NET_SFTP_INIT, "\0\0\0\3")) {
            return false;
        }

        $response = $this->_get_sftp_packet();
        if ($this->packet_type != NET_SFTP_VERSION) {
            user_error('Expected SSH_FXP_VERSION', E_USER_NOTICE);
            return false;
        }

        extract(unpack('Nversion', $this->_string_shift($response, 4)));
        $this->version = $version;
        while (!empty($response)) {
            extract(unpack('Nlength', $this->_string_shift($response, 4)));
            $key = $this->_string_shift($response, $length);
            extract(unpack('Nlength', $this->_string_shift($response, 4)));
            $value = $this->_string_shift($response, $length);
            $this->extensions[$key] = $value;
        }

        /*
         SFTPv4+ defines a 'newline' extension.  SFTPv3 seems to have unofficial support for it via 'newline@vandyke.com',
         however, I'm not sure what 'newline@vandyke.com' is supposed to do (the fact that it's unofficial means that it's
         not in the official SFTPv3 specs) and 'newline@vandyke.com' / 'newline' are likely not drop-in substitutes for
         one another due to the fact that 'newline' comes with a SSH_FXF_TEXT bitmask whereas it seems unlikely that
         'newline@vandyke.com' would.
        */
        /*
        if (isset($this->extensions['newline@vandyke.com'])) {
            $this->extensions['newline'] = $this->extensions['newline@vandyke.com'];
            unset($this->extensions['newline@vandyke.com']);
        }
        */

        $this->request_id = 1;

        /*
         A Note on SFTPv4/5/6 support:
         <http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-5.1> states the following:

         "If the client wishes to interoperate with servers that support noncontiguous version
          numbers it SHOULD send '3'"

         Given that the server only sends its version number after the client has already done so, the above
         seems to be suggesting that v3 should be the default version.  This makes sense given that v3 is the
         most popular.

         <http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-5.5> states the following;

         "If the server did not send the "versions" extension, or the version-from-list was not included, the
          server MAY send a status response describing the failure, but MUST then close the channel without
          processing any further requests."

         So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and
         a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4?  If it only implements
         v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed
         in draft-ietf-secsh-filexfer-13 would be quite impossible.  As such, what Net_SFTP would do is close the
         channel and reopen it with a new and updated SSH_FXP_INIT packet.
        */
        switch ($this->version) {
            case 2:
            case 3:
                break;
            default:
                return false;
        }

        $this->pwd = $this->_realpath('.', false);

        $this->_save_dir($this->pwd);

        return true;
    }
319
public function login($username, $password)
	{
		$response = $this->http->get($this->getUrl('oauth2/access_token'), array(
			'grant_type'	=>	'password ',
			'username'		=>	$username,
			'password'		=>	$password,
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
		));
		$this->result = $response->json(true);
		if(!isset($this->result['error_code']))
		{
			return $this->accessToken = $this->result['access_token'];
		}
		else
		{
			throw new ApiException(isset($this->result['error']) ? $this->result['error'] : '', $this->result['error_code']);
		}
	}
981580
protected function createAuthCodeClient(ClientRepository $clients)
    {
        $userId = $this->option('user_id') ?: $this->ask(
            'Which user ID should the client be assigned to?'
        );

        $name = $this->option('name') ?: $this->ask(
            'What should we name the client?'
        );

        $redirect = $this->option('redirect_uri') ?: $this->ask(
            'Where should we redirect the request after authorization?',
            url('/auth/callback')
        );

        $client = $clients->create(
            $userId, $name, $redirect
        );

        $this->info('New client created successfully.');

        $this->outputClientDetails($client);
    }
1189030
public function login($username, $password)
  {
    $this->execute("login", array("client_login_name" => $username, "client_login_password" => $password));
    $this->whoamiReset();

    $crypt = new TeamSpeak3_Helper_Crypt($username);

    $this->setStorage("_login_user", $username);
    $this->setStorage("_login_pass", $crypt->encrypt($password));

    TeamSpeak3_Helper_Signal::getInstance()->emit("notifyLogin", $this);
  }
599474
public static function pull($config = null, $clientId = null)
    {
        // Return if not enabled
        if (!self::isEnabled($config)) {
            return null;
        }

        $tokens = null;
        $cachePath = self::cachePath($config);
        if (file_exists($cachePath)) {
            // Read from the file
            $cachedToken = file_get_contents($cachePath);
            if ($cachedToken && JsonValidator::validate($cachedToken, true)) {
                $tokens = json_decode($cachedToken, true);
                if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) {
                    // If client Id is found, just send in that data only
                    return $tokens[$clientId];
                } else if ($clientId) {
                    // If client Id is provided, but no key in persisted data found matching it.
                    return null;
                }
            }
        }
        return $tokens;
    }
827616
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
    {
        try {
            $event = new ApiAuthenticateEvent();

            if (null !== $token->getCredentials()) {
                $event->setUserName($token->getUsername());
                $event->setPassword($token->getCredentials());
                $this->dispatcher->dispatch(ApiAuthenticationEvents::AUTHENTICATE, $event);
            } elseif ($token->getUser() instanceof User) {
                //if we have no password then only way to authenticate is by api key
                $event->setApiKey($token->getUser()->getApiKey());
                $this->dispatcher->dispatch(ApiAuthenticationEvents::API_KEY_AUTHENTICATE, $event);
            }

            $user = $userProvider->loadUserByUsername($token->getUsername());
        } catch (UsernameNotFoundException $e) {
            throw new AuthenticationException($e->getMessage());
        }

        return new UsernamePasswordToken(
            $user,
            $user->getPassword(),
            $providerKey,
            $user->getRoles()
        );
    }
637013
public function createIdToken($client_id, $userInfo, $nonce = null, $userClaims = null, $access_token = null)
    {
        // pull auth_time from user info if supplied
        list($user_id, $auth_time) = $this->getUserIdAndAuthTime($userInfo);

        $token = array(
            'iss'        => $this->config['issuer'],
            'sub'        => $user_id,
            'aud'        => $client_id,
            'iat'        => time(),
            'exp'        => time() + $this->config['id_lifetime'],
            'auth_time'  => $auth_time,
        );

        if ($nonce) {
            $token['nonce'] = $nonce;
        }

        if ($userClaims) {
            $token += $userClaims;
        }

        if ($access_token) {
            $token['at_hash'] = $this->createAtHash($access_token, $client_id);
        }

        return $this->encodeToken($token, $client_id);
    }
1212692
protected static function JsSSOString($User, $ClientID, $Secret)
    {
        if (!isset($User['client_id']))
            $User['client_id'] = $ClientID;

        $String = base64_encode(json_encode($User));
        $Timestamp = time();
        $Hash = hash_hmac('sha1', "$String $Timestamp", $Secret);

        $Result = "$String $Hash $Timestamp hmacsha1";
        return $Result;
    }
1037233
public function getCredentialsByClientId($clientId)
    {
        return $this->createCommand()
            ->setRequest($this->client->get(Url::factory('credentials')->setQuery(array('clientId' => $clientId))))
            ->setResponseClass('Maba\OAuthCommerceInternalClient\Entity\ClientCredentials[]')
        ;
    }
236198
public function getSessionTokenWithLogin($requestToken, $username, $password)
    {
        $validatedRequestToken = $this->validateRequestTokenWithLogin($requestToken, $username, $password);

        if (!$validatedRequestToken['success']) {
            throw new \InvalidArgumentException('Unable to validate the request_token, please check your credentials.');
        }

        return $this->getNewSession($validatedRequestToken['request_token']);
    }
34884
public function createClient(Client $client, $password)
    {
        $data = $client->toArray();
        $data['password_confirm'] = $data['password'] = $password;
        $data['send_email'] = 0;
        $data['submit'] = 'Save';

        $response = $this->post('/en/client/add', $data);

        if ($response->getStatusCode() == 200) {
            $error = $this->getBetween((string)$response->getBody(), '<ul class="errors">', '</ul>');
            $error = $this->getBetween($error, '<li>', '</li>');
            throw new YouHostingException("Unable to create profile: " . $error);
        }

        $response = $this->get($response->getHeader('Location'));

        $client->id = $this->getBetweenReverse((string)$response->getBody(), '/en/client/view/id/', '">' . $client->email);
        return $client;
    }
772139
protected function createPasswordClient(ClientRepository $clients)
    {
        $name = $this->option('name') ?: $this->ask(
            'What should we name the password grant client?',
            config('app.name').' Password Grant Client'
        );

        $client = $clients->createPasswordGrantClient(
            null, $name, 'http://localhost'
        );

        $this->info('Password grant client created successfully.');
        $this->line('<comment>Client ID:</comment> '.$client->_id);
        $this->line('<comment>Client Secret:</comment> '.$client->secret);
    }
936428
public function getSsoLink($writerId, $pid, $email)
    {
        $result = $this->getCommand('GetSSOLink', [
            'writerId' => $writerId,
            'pid' => $pid,
            'email' => $email
        ])->execute();
        if (!isset($result['ssoLink'])) {
            throw new ClientException('Getting SSO link failed. ' . (isset($result['error']) ? $result['error'] : ''));
        }
        return $result['ssoLink'];
    }
1257527
public function addAuthMiddleware($token, $clientId)
    {
        $this->stack->push(Middleware::mapRequest(function (RequestInterface $request) use ($token, $clientId) {
            return (new AuthMiddleware($token, $clientId))->addAuthHeader($request);
        }));
    }