> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Generic Provider (logic.generic_provider)

> Holds one credential of the organization and hands it to a logic.code, which reads it by route.

A `logic.generic_provider` is a provider: a component that holds a credential and is wired to the component that uses
it, rather than placed in the flow. It names one credential of the organization by its alias and serves no interface,
so it is for a [`logic.code`](https://docs.blobhub.io/blob-types/workflow/workflows/component-code) that needs a secret, such as an API key
for a service the platform has no component for.

| Route | Category | Value | Notes |
| :- | :- | :- | :- |
| `credential` | Data input | `credential` | Required. The alias of a credential of the organization. |

A `logic.generic_provider` has no flow ports and no outputs. The wire that connects it to a component is its provider
reference, a socket with no route of its own.

```mermaid theme={null}
graph LR
    Provider[logic.generic_provider] -- "serves, route: keys" --> Code[logic.code]
    Provider -- "credential: alias" --> Credential[(credential)]
```

The diagram draws what is served. In the definition the connection is written from the step: its `source` is the
`logic.code` with `source_port` `provider_input`, and its `target` is the provider with `target_port`
`provider_reference`.

## Wiring it to a `logic.code`

The route of the connection from the `logic.code` to the provider names the provider inside the program, so a program
can read several providers by route. A program reads the credential with `get_provider_credential`, giving the
connection's route and the provider's port route, which is always `credential`
([Credentials](https://docs.blobhub.io/blob-types/workflow/workflows/component-code.md#credentials)). The call returns the credential row, whose
`body` holds the secret.

* **A provider serves no interface.** Its `interfaces` list is empty, so it is not the model or store that another
  component asks its provider for. It exists for a `logic.code` to read.
* **The connection needs a route.** A connection without one fails the node with an error event, `Provider "<name>" is
  connected without a route, so its credentials cannot be resolved`.
* **A route the program does not know returns `None`.** So does a provider wired with a different route, and so does a
  `logic.code` with no provider at all.

## When the credential is missing

The `credential` port is required. A definition whose `logic.generic_provider` has no alias fails [its
check](https://docs.blobhub.io/blob-types/workflow/operations/check-definition.md) with ``Port `credential` (category: `data_input`) is
required``. An alias that names no credential of the organization fails the node that uses it before its program runs,
with an error event `"<alias>" credential alias not found`.

## Example

Halden Systems calls its carrier-rates service from a `logic.code`, with the key stored as the credential
`carrier_rates_key`. The provider holds the alias, and the connection from the code component carries the route `keys`.

```json theme={null}
{
  "components": [
    {"id": "rates_provider", "category": "provider", "type": "logic.generic_provider", "name": "Carrier rates key",
     "position": {"x": 300, "y": 150},
     "ports": [{"category": "data_input", "route": "credential",
                "value": {"type": "credential", "alias": "carrier_rates_key"}}]}
  ],
  "connections": [
    {"id": "c1", "source_id": "<code component>", "target_id": "rates_provider", "route": "keys",
     "source_port": "provider_input", "target_port": "provider_reference"}
  ]
}
```

The program reads the key with `get_provider_credential("keys", "credential")["body"]`. The first argument is the
route of connection `c1`, the second is the provider's port.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.