temporalio / sdk-java

Temporal Java SDK
https://temporal.io
Apache License 2.0
211 stars 142 forks source link

API key client option #1997

Closed cretz closed 4 months ago

cretz commented 7 months ago

Describe the solution you'd like

See https://github.com/temporalio/features/issues/426

Quinn-With-Two-Ns commented 5 months ago

Is AuthorizationGrpcMetadataProvider sufficient or do we need to add another way to set the API key?

example:

    // Create the Workflow service stub.
    WorkflowServiceStubsOptions.Builder stubOptions =
        WorkflowServiceStubsOptions.newBuilder()
            .setChannelInitializer(
                (channel) -> {
                  channel.overrideAuthority(SERVER_NAME);
                  channel.intercept(MetadataUtils.newAttachHeadersInterceptor(metadata));
                })
            .addGrpcMetadataProvider(
                new AuthorizationGrpcMetadataProvider(() -> "Bearer " + API_KEY))
            .setTarget(ENDPOINT);
cretz commented 5 months ago

I was hoping to have a literal setApiKey even if it's sugar, but can be convinced otherwise if we don't think it's needed here. I do think there may be a time soon where setCloudApiKey would default the target too, but that's for later.