Skip to content

Commit 8b2893c

Browse files
authored
NQ example: fix token usage in code & docs (#401)
Towards linear/OND-1489
1 parent 1ce3a07 commit 8b2893c

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

java/com/engflow/notificationqueue/Client.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ public static void main(String[] args) throws Exception {
8484
}
8585
try {
8686
final Metadata header = new Metadata();
87-
Metadata.Key<String> userKey =
88-
Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER);
89-
header.put(userKey, "Bearer " + clientOptions.getOption("token"));
87+
Metadata.Key<String> methodKey =
88+
Metadata.Key.of("x-engflow-auth-method", Metadata.ASCII_STRING_MARSHALLER);
89+
header.put(methodKey, "jwt-v0");
90+
Metadata.Key<String> tokenKey =
91+
Metadata.Key.of("x-engflow-auth-token", Metadata.ASCII_STRING_MARSHALLER);
92+
header.put(tokenKey, clientOptions.getOption("token"));
9093
pull(channel, clientOptions.getOption("queue_name"), header, forwardChannel);
9194
} finally {
9295
if (channel != null) {

java/com/engflow/notificationqueue/README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,23 @@ bazel run //java/com/engflow/notificationqueue:client -- \
4444
```
4545

4646

47-
### Using tokens to run the client
47+
### Using JWT to run the client
4848

49-
In the second for case authentication you should have a token issued by a
50-
valid authority. In this example we use cluster used by the
51-
[open-source envoy-mobile](https://github.com/envoyproxy/envoy-mobile) project.
52-
It uses [GitHub tokens](https://docs.github.com/en/actions/security-guides/automatic-token-authentication) for authentication method but your server may support
53-
other token provider. To execute the client against the envoy-mobile cluster add
54-
the argument
49+
In the second authentication case you should count with a valid token. On EngFlow clusters you may get a new access token by
50+
accessing the cluster's UI under the tab `Getting Started`. To execute the client against your cluster, add the argument
5551

56-
1. `--token=token issued by valid authority`
52+
1. `--token=your-long-JWT-token`
5753
holds the authentication token.
5854
Needed for both `grpc://` and `grpcs://` connections
5955

6056
Run the client using
6157

6258
```bash
6359
bazel run //java/com/engflow/notificationqueue:client -- \
64-
'--notification_queue_endpoint=grpcs://envoy.cluster.engflow.com' '--queue_name=eventstore/lifecycle-events' \
65-
'--token=ghs_vHu2hAHwhg2EjBXrs4koOxk5PfSKVb2lzAUM'
60+
'--notification_queue_endpoint=grpcs://$CLUSTER.cluster.engflow.com' '--queue_name=eventstore/lifecycle-events' \
61+
'--token=DKiJ3eic9l150dDmzdMsaiu0K5boBle0UlkCefbgwzBE7G7FItgi2AOFpz6pkcMUFV3SkpAGikMckcaQhTTKUmGeZKpLh9gT6vTsi0v'
6662
```
6763

68-
Note: The token provided in the example is not valid. You should count with a
69-
valid envoy-mobile token to use envoy-cluster. Change your target cluster and
70-
acquire a valid token for executing the client.
7164

7265
### Forwarding data to external server
7366

0 commit comments

Comments
 (0)