Checks if client credentials are valid.

@param $client_id
@param null $client_secret
@return bool
191933
public function checkClientCredentials($client_id, $client_secret = null)
	{
		$client = $this->repo->find($client_id);

		if(!$client) {
			return false;
		}

		return $client_secret == $client->getSecret();
	}
163257
public static function setClientSecret($client_secret){
      if (!isset(self::$_config)){
        self::initialize();
      }
      self::$_config->configure(['CLIENT_SECRET' => $client_secret]); 
    }
101239
public static function useStaging($client_id, $client_secret, $api_version = null)
    {
        if (self::$production !== null) {
            throw new RuntimeException('API mode has already been set.');
        }
        self::$production    = false;
        self::$client_id     = $client_id;
        self::$client_secret = $client_secret;
        self::$api_version   = $api_version;
    }
508557
function Yubikey(clientId, secretKey) {
  this.clientId = clientId || process.env['YUBIKEY_CLIENT_ID'];
  this.secretKey = secretKey || process.env['YUBIKEY_SECRET_KEY'];

  if (!(this.clientId && this.secretKey)) {
    throw new Error("need client id and secret key");
  }
}
176172
public function removeCredential($id)
    {
        try {
            $this->_request(self::URN_REMOVE, ['client_id' => $id]);
            return true;
        } catch (NotFoundException $e) {
            return false;
        }
    }
522824
def setup(cls, client_id, client_secret):
        
        cls.client_id = client_id
        cls.client_secret = client_secret
1009894
public function validateRequest(RequestInterface $request, ResponseInterface $response)
	{
		// check HTTP basic auth headers for client id/secret
		if (!is_null($request->headers('PHP_AUTH_USER')) && !is_null($request->headers('PHP_AUTH_PW')))
		{
			$clientData = array(
				'client_id'     => $request->headers('PHP_AUTH_USER'),
				'client_secret' => $request->headers('PHP_AUTH_PW')
			);
		}

		// if we allow credentials via request body look there
		if ($this->config['allow_credentials_in_request_body'])
		{
			// check for client id in request
			if (!is_null($request->request('client_id')))
			{
				$clientData = array(
					'client_id'     => $request->request('client_id'),
					'client_secret' => $request->request('client_secret')
				);
			}
		}

		// must have client id
		if (!isset($clientData['client_id']) || $clientData['client_id'] == '')
		{
			$message = $this->config['allow_credentials_in_request_body'] ? ' or body' : '';
			$response->setError(400, 'invalid_client', 'Client credentials were not found in the headers'.$message);
			return false;
		}

		// check to see if we have client secret
		if (!isset($clientData['client_secret']) || $clientData['client_secret'] == '')
		{
			// invalid if we dont have client secret and public clients are off
			if (!$this->config['allow_public_clients'])
			{
				$response->setError(400, 'invalid_client', 'client credentials are required');
				return false;
			}

			// check storage if client is public client
			if (!$this->storage->isPublicClient($clientData['client_id']))
			{
				$response->setError(400, 'invalid_client', 'This client is invalid or must authenticate using a client secret');
				return false;
			}
		}
		// if we do have a secret lets verify them
		elseif ($this->storage->checkClientCredentials($clientData['client_id'], $clientData['client_secret']) === false)
		{
			$response->setError(400, 'invalid_client', 'The client credentials are invalid');
			return false;
		}

		// store data locally
		$this->clientData = $clientData;
		return true;
	}
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());
    }
1374867
public function removeClientUser($client_id, $user_id)
    {
        $sql    = 'DELETE from %s where client_id = :client_id and user_id = :user_id';
        $sql    = sprintf($sql, $this->config['client_user_table']);
        $params = array_map('trim', compact('client_id', 'user_id'));

        return $this->db->prepare($sql)->execute($params);
    }
437138
public function isPublicClient($client_id)
	{
		// get client details
		$client = $this->getClientDetails($client_id);

		// make sure its an available client (aka not deleted)
		return $client && $client['state'] != 2 ? true : false;
	}
1036922
public function verifyResponse($response, $clientIp = null)
    {
        if (empty($response)) {
            return false;
        }

        // Return true if response already verfied before.
        if (in_array($response, $this->verifiedResponses)) {
            return true;
        }

        $verifyResponse = $this->sendRequestVerify([
            'secret' => $this->secret,
            'response' => $response,
            'remoteip' => $clientIp,
        ]);

        if (isset($verifyResponse['success']) && $verifyResponse['success'] === true) {
            // A response can only be verified once from google, so we need to
            // cache it to make it work in case we want to verify it multiple times.
            $this->verifiedResponses[] = $response;
            return true;
        } else {
            return false;
        }
    }
233357
public static function validate(string $token, string $secret): bool
    {
        $parse = self::parser($token, $secret);

        if (!self::validateWithExpiration($parse)) {
            return false;
        }

        if (!self::validateNotBefore($parse)) {
            return false;
        }

        return true;
    }
588920
public function get_access_token( $code, $client_id, $client_secret ) {
		$contents = $this->get_contents( 'token_url', $this->get_access_token_params( $code, $client_id, $client_secret ) );
		$response = @json_decode( $contents, true );
		if ( empty( $response ) || ! empty( $response['error'] ) ) {
			$this->app->log( 'social response error', [
				'$contents' => $contents,
				'$response' => $response,
			] );

			return false;
		}

		return $response['access_token'];
	}
941728
public function removeCredentialsByClientId($clientId)
    {
        return $this->createCommand()
            ->setRequest($this->client->delete(Url::factory('credentials')->setQuery(array('clientId' => $clientId))))
        ;
    }
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);
	}
963980
def authenticate(self, client_id, client_secret, use_cache=True):
        
        # We will reuse a token for as long as we have one cached
        # and it hasn't expired.
        if use_cache:
            client = self._get_client_from_cache(client_id)
            if (client) and (not self.is_expired_token(client)):
                self.authenticated = True
                self.client = client
                return

        # Let's authenticate the client
        client = {
            'id': client_id,
            'secret': client_secret
        }

        res = self._authenticate_client(client_id, client_secret)
        client.update(res)

        expires = datetime.datetime.now() + \
                  datetime.timedelta(seconds=res['expires_in'])
        client['expires'] = expires.isoformat()

        # Cache it for repeated use until expired
        self._write_to_uaa_cache(client)

        self.client = client
        self.authenticated = True
510585
public final function isValidAuth(ClientAuth $clientAuth) {
		return $clientAuth->publicKey === $this->getPublicKey() && $clientAuth->token === $this->getToken();
	}