File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
temporal-serviceclient/src/main/java/io/temporal/serviceclient Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 25
25
import com .uber .m3 .tally .Scope ;
26
26
import io .grpc .*;
27
27
import io .grpc .netty .shaded .io .netty .handler .ssl .SslContext ;
28
+ import io .temporal .authorization .AuthorizationGrpcMetadataProvider ;
29
+ import io .temporal .authorization .AuthorizationTokenSupplier ;
28
30
import java .time .Duration ;
29
31
import java .util .ArrayList ;
30
32
import java .util .Collection ;
@@ -508,6 +510,23 @@ public T addGrpcMetadataProvider(GrpcMetadataProvider grpcMetadataProvider) {
508
510
return self ();
509
511
}
510
512
513
+ /**
514
+ * Add a {@link AuthorizationGrpcMetadataProvider} to the gRPC metadata providers that supplies
515
+ * an authentication token on each gRPC request.
516
+ *
517
+ * @param apiKey authentication token supplier to be called on each gRPC request. SDK will
518
+ * automatically add the "Bearer " prefix.
519
+ * @return {@code this}
520
+ */
521
+ public T addApiKey (AuthorizationTokenSupplier apiKey ) {
522
+ addGrpcMetadataProvider (
523
+ new AuthorizationGrpcMetadataProvider (
524
+ () -> {
525
+ return "Bearer " + apiKey .supply ();
526
+ }));
527
+ return self ();
528
+ }
529
+
511
530
/**
512
531
* @param grpcMetadataProviders gRPC metadata/headers providers to be called on each gRPC
513
532
* request to supply additional headers
You can’t perform that action at this time.
0 commit comments