Create a new password grant client.

@param  \MoeenBasra\LaravelPassportMongoDB\ClientRepository  $clients
@return void
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);
    }
1279005
public function authenticate(ClientContract $client): void
    {
        if ($this->cookie !== '' || $this->isAuthenticating) {
            return;
        }

        $this->isAuthenticating = true;
        $response = $client->request('POST', '/user/login', [
            'login' => $this->username,
            'password' => $this->password,
        ]);
        $this->isAuthenticating = false;

        if ($response->isStatusCode(200)) {
            $this->cookie = $response->cookie();
        }
    }
1090179
public static function fetchClient($client_id, $client_secret = null)
	{
		$query = DB::table('oauth_clients')->where('id', $client_id);
		if (null !== $client_secret) {
			$query->where('secret', $client_secret);
		}
		$client = $query->first();
		
		if (!$client) {
			return null;
		}
		
		return new Authentication\Client($client_id, (array) $client);
	}
1145135
public function connect(ClientInterface $client)
    {
        /**
         * @var Social $account
         */
        $account = new Social();
        $account->connectWithUser($client);
        $this->action->successUrl = Url::to(['/user/settings/networks']);
    }
122392
protected function authClient(): ClientInterface
    {
        return new Client(new BasicAuth($this->clientId, $this->clientSecret), $this->auth_server);
    }
32223
public function handle(ClientRepository $clients)
    {
        if ($this->option('personal')) {
            return $this->createPersonalClient($clients);
        }

        if ($this->option('password')) {
            return $this->createPasswordClient($clients);
        }

        $this->createAuthCodeClient($clients);
    }
962622
public function addHttpClient($client): void
    {
        if (!$client instanceof HttpClientPoolItem) {
            $client = new HttpClientPoolItem($client);
        }

        $this->clientPool[] = $client;
    }
689903
protected function createClientCredentialsClient(ClientRepository $clients)
    {
        $name = $this->option('name') ?: $this->ask(
            'What should we name the client?',
            config('app.name').' ClientCredentials Grant Client'
        );

        $client = $clients->create(
            null, $name, ''
        );

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

        $this->outputClientDetails($client);
    }
983770
protected function configureClient(Client $client, array $settings)
    {
        $configuredClient = $client ?: new Client();

        // Set authentication, if necessary:
        if (!empty($settings['httpUser']) && !empty($settings['httpPass'])) {
            $configuredClient->setAuth($settings['httpUser'], $settings['httpPass']);
        }

        // Set up assorted client options from $settings array:
        $configuredClient->setOptions($this->getClientOptions($settings));

        return $configuredClient;
    }
1222250
public function addClient($client, RequestMatcher $requestMatcher): void
    {
        $this->clients[] = [
            'matcher' => $requestMatcher,
            'client' => new FlexibleHttpClient($client),
        ];
    }
870834
public function setPassword($password, $publicKeyByIp = true) {
		if($this->auth) {
			throw new \Exception('Password already defined');
		}
		$this->convertEncoding($password, self::CLIENT_ENCODING, $this->serverEncoding);
		$this->auth = new Auth($password, $publicKeyByIp);
		if($this->client) {
			$this->isAuthorized = $this->client->auth && $this->auth->isValidAuth($this->client->auth);
		}
	}
1161316
public function injectSettings(array $settings) {
		if (isset($settings['client']['serviceBaseUri'])) {
			$this->clientServiceBaseUri = $settings['client']['serviceBaseUri'];
		}
		if (isset($settings['client']['publicKeyFingerprint'])) {
			$this->clientPublicKeyFingerprint = $settings['client']['publicKeyFingerprint'];
		}
	}
1252037
public function add(ClientInterface $client)
    {
        $this->clients[$client->getClientType()][$client->getClientIdentifier()] = $client;

        return $this;
    }
612011
public function refresh() {
    $grant = new ClientCredentialsGrantRequest($this->clientId, $this->clientSecret, $this->scopes);
    $tokens = $grant->getTokens();

    $this->accessToken = $tokens->{"access_token"};
    $this->expiresAt = Util::calculateExpiryTime($tokens->{"expires_in"});
  }
1089010
public function clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM')
    {
        $this->client_cert          = $cert;
        $this->client_key           = $key;
        $this->client_passphrase    = $passphrase;
        $this->client_encoding      = $encoding;

        return $this;
    }
773079
public function setClient(ClientInterface $client = null): self
    {
        if (null === $client) {
            $this->client = new Client();

            return $this;
        }

        $this->client = $client;

        return $this;
    }
270980
public function checkRestrictedGrantType($clientUuid, $grantType)
    {
        $client = $this->getClientDataMapper()->findByUuid($clientUuid);

        if (! $client instanceof Entity\Client) {
            return false;
        }

        $clientGrantTypes = $client->getGrantTypes();

        if (empty($clientGrantTypes)) {
            return true;
        }

        return in_array($grantType, $clientGrantTypes);
    }