Get the client.

@param string $clientId
@param string $clientSecret
@param string $redirectUri
@param string $grantType

@return null|\League\OAuth2\Server\Entity\ClientEntity
175318
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
    {
        $query = null;

        if (!is_null($redirectUri) && is_null($clientSecret)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_client_endpoints.redirect_uri as redirect_uri',
                       'oauth_clients.name as name')
                   ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_client_endpoints.redirect_uri', $redirectUri);
        } elseif (!is_null($clientSecret) && is_null($redirectUri)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_clients.name as name')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_clients.secret', $clientSecret);
        } elseif (!is_null($clientSecret) && !is_null($redirectUri)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_client_endpoints.redirect_uri as redirect_uri',
                       'oauth_clients.name as name')
                   ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_clients.secret', $clientSecret)
                   ->where('oauth_client_endpoints.redirect_uri', $redirectUri);
        }

        if ($this->limitClientsToGrants === true && !is_null($grantType)) {
            $query = $query->join('oauth_client_grants', 'oauth_clients.id', '=', 'oauth_client_grants.client_id')
                   ->join('oauth_grants', 'oauth_grants.id', '=', 'oauth_client_grants.grant_id')
                   ->where('oauth_grants.id', $grantType);
        }

        $result = $query->first();

        if (is_null($result)) {
            return;
        }

        return $this->hydrateEntity($result);
    }
740145
public function implicitCreateAskResourceOwnerForApprovalResponse(
        ClientInterface $client,
        string $redirectUri = null,
        bool $isScopeModified = false,
        array $scopeList = null,
        string $state = null,
        array $extraParameters = []
    ): ResponseInterface {
        $response = $this->getIntegration()->createAskResourceOwnerForApprovalResponse(
            ResponseTypes::IMPLICIT,
            $client,
            $redirectUri,
            $isScopeModified,
            $scopeList,
            $state,
            $extraParameters
        );

        $this->logInfo('Created response asking resource owner for scope approval (implicit grant).');

        return $response;
    }
1051364
public function getClientDetails($client_id)
    {
        if (!isset($this->clientCredentials[$client_id])) {
            return false;
        }

        $clientDetails = array_merge(array(
            'client_id'     => $client_id,
            'client_secret' => null,
            'redirect_uri'  => null,
            'scope'         => null,
        ), $this->clientCredentials[$client_id]);

        return $clientDetails;
    }
1024478
public function getClientScope($client_id)
    {
        // Get Client
        $client = $this->em->getRepository('OAuth2ServerBundle:Client')->find($client_id);

        if (!$client) {
            return false;
        }

        return implode(' ', $client->getScopes());
    }
939550
private function compareUris($redirect_uri, $clientRedirectUri)
    {
        if (!$redirect_uri || !$clientRedirectUri) {
            return false;
        }

        $wanted = array_fill_keys(['scheme', 'host', 'port', 'path'], true);

        // gets only scheme, host, port, path from uri
        $redirect_uri = array_intersect_key(parse_url($redirect_uri), $wanted);
        $clientRedirectUri = array_intersect_key(parse_url($clientRedirectUri), $wanted);

        return strcmp(implode($redirect_uri), implode($clientRedirectUri)) === 0;
    }
917993
public function getLoginUrl(string $redirectUri = '', string $userType = 'admin', string $state = '')
    {
        $redirectUri || $redirectUri = $this->app->config['redirect_uri_single'];
        $state || $state = rand();
        $params = [
            'appid' => $this->app['config']['corp_id'],
            'redirect_uri' => $redirectUri,
            'usertype' => $userType,
            'state' => $state,
        ];

        return 'https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?'.http_build_query($params);
    }
802657
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->outputClientDetails($client);
    }
958296
protected function getValidClientAndRedirectUri(string $clientId = null, string $redirectFromQuery = null): array
    {
        $client           = null;
        $validRedirectUri = null;

        if ($clientId !== null &&
            ($client = $this->readClientByIdentifier($clientId)) !== null
        ) {
            $validRedirectUri = $this->selectValidRedirectUri($client, $redirectFromQuery);
            if ($validRedirectUri === null) {
                $this->logDebug(
                    'Choosing valid redirect URI for client failed.',
                    ['client_id' => $clientId, 'redirect_uri_from_query' => $redirectFromQuery]
                );
            }
        } else {
            $this->logDebug('Client is not found.', ['client_id' => $clientId]);
        }

        return [$client, $validRedirectUri];
    }
748337
public function checkRestrictedGrantType($client_id, $grant_type)
	{
		$client = $this->repo->find($client_id);

		if(!$client) {
			return false;
		}

		$restrictedTypes = $client->getRestrictedGrantTypes();

		// Null restricted type assuemd to be true.
		if(is_null($restrictedTypes)) {
			return true;
		}


		return in_array($grant_type, $restrictedTypes);
	}
1037233
public function getCredentialsByClientId($clientId)
    {
        return $this->createCommand()
            ->setRequest($this->client->get(Url::factory('credentials')->setQuery(array('clientId' => $clientId))))
            ->setResponseClass('Maba\OAuthCommerceInternalClient\Entity\ClientCredentials[]')
        ;
    }
575393
public function getBearerToken($grantType = 'client_credentials')
    {
        $request = $this->createRequest('/oauth2/token');
        $request->setPostParameter('grant_type', $grantType);
        $this->signRequest($request, new BasicToken());

        return $this->createBearerToken($this->sendRequest($request));
    }
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);
    }
126592
private function getClientInternal($type = null) {
		if ($type != null) {
			if (isset($this->clients[$type])) {
				return $this->clients[$type];
			} else {
				throw new \Exception("No http client with type '$type' found.");
			}
		} else {
			foreach ($this->clients as $client) {
				if ($client->isSupported()) {
					return $client;
				}
			}
			throw new \Exception('No supported http client found.');
		}
	}
265674
public static function get(int $oauthClientId, array $customHeaders = []): BunqResponseOauthClient
    {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->get(
            vsprintf(
                self::ENDPOINT_URL_READ,
                [static::determineUserId(), $oauthClientId]
            ),
            [],
            $customHeaders
        );

        return BunqResponseOauthClient::castFromBunqResponse(
            static::fromJson($responseRaw, self::OBJECT_TYPE_GET)
        );
    }
191933
public function checkClientCredentials($client_id, $client_secret = null)
	{
		$client = $this->repo->find($client_id);

		if(!$client) {
			return false;
		}

		return $client_secret == $client->getSecret();
	}
1138564
public function exchangeCodeForToken($codeValue, $redirectUri)
    {
        return $this->createCommand()
            ->setRequest($this->client->post('token'))
            ->setBodyEntity(array(
                'grant_type' => 'authorization_code',
                'code' => $codeValue,
                'redirect_uri' => $redirectUri,
            ), 'urlencoded')
            ->setResponseClass('Maba\OAuthCommerceClient\Entity\AccessToken')
        ;
    }
937057
public function updateClientSecret($clientId, $clientSecret)
    {
        ValidationUtility::ensureStringOrInteger('$clientId', $clientId);
        ValidationUtility::ensureString('$clientSecret', $clientSecret);

        $request = new ClientSecretUpdateRequest();
        $request->setClientSecret($clientSecret);

        return $this->callServicePostApi(
            '\Authlete\Dto\ClientSecretUpdateResponse::fromJson',
            self::$CLIENT_SECRET_UPDATE_API_PATH . $clientId,
            null, $request);
    }