createOIDCClient function

OIDCServiceClient createOIDCClient(
  1. String apiEndpoint, {
  2. int port = 443,
  3. Map<String, String>? metadata,
  4. Iterable<MetadataProvider>? metadataProviders,
  5. Iterable<ClientInterceptor>? interceptors,
})

Create a new OIDCServiceClient to access the OIDC API of ZITADEL.

The client can be configured by adding default metadata and/or interceptors. Also with the metadataProviders one can add a list of providers that will be called for each RPC call. For example, the provider may attach access tokens from static or service account sources.

Example

Simple client:

final client = createOIDCClient('api.zitadel.ch');

Client with static access token:

final client = createOIDCClient(
  'api.zitadel.ch',
  metadataProviders: [accessTokenProvider('token')],
);

Client with service account access token:

final client = createOIDCClient(
  'api.zitadel.ch',
  metadataProviders: [
    serviceAccountProvider(
      'https://audience.zitadel.ch',
      serviceAccount,
      AuthenticationOptions(apiAccess: true),
    ),
  ],
);

Implementation

OIDCServiceClient createOIDCClient(String apiEndpoint,
        {int port = 443,
        Map<String, String>? metadata,
        Iterable<MetadataProvider>? metadataProviders,
        Iterable<ClientInterceptor>? interceptors}) =>
    _createClient(
      apiEndpoint,
      OIDCServiceClient.new,
      port: port,
      metadata: metadata,
      metadataProviders: metadataProviders,
      interceptors: interceptors,
    );