public function HybridCredentials::__construct in Apigee Edge 8
HybridCredentials constructor.
Parameters
\Drupal\key\KeyInterface $key: The key entity which stores the API credentials.
Throws
\InvalidArgumentException An InvalidArgumentException is thrown if the key type does not implement EdgeKeyTypeInterface.
Overrides Credentials::__construct
File
- src/
Connector/ HybridCredentials.php, line 42
Class
- HybridCredentials
- The API credentials for HybridCredentials.
Namespace
Drupal\apigee_edge\ConnectorCode
public function __construct(KeyInterface $key) {
if ($key
->getKeyType() instanceof EdgeKeyTypeInterface && ($auth_type = $key
->getKeyType()
->getAuthenticationType($key)) && ($auth_type === EdgeKeyTypeInterface::EDGE_AUTH_TYPE_JWT || $auth_type === EdgeKeyTypeInterface::EDGE_AUTH_TYPE_DEFAULT_GCE_SERVICE_ACCOUNT)) {
parent::__construct($key);
}
else {
throw new InvalidArgumentException("The `{$key->id()}` key is not configured for Hybrid Authentication.");
}
}