From b97140687a840a9e3fedf3352a9d301eca58298f Mon Sep 17 00:00:00 2001 From: noerog <32459203+noerog@users.noreply.github.com> Date: Wed, 3 Jan 2018 10:28:21 -0500 Subject: [PATCH] Add region tags to JWT refresh. --- .../main/java/com/example/cloud/iot/examples/MqttExample.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iot/api-client/manager/src/main/java/com/example/cloud/iot/examples/MqttExample.java b/iot/api-client/manager/src/main/java/com/example/cloud/iot/examples/MqttExample.java index 7c7c6b5e42e..d959f6003a6 100644 --- a/iot/api-client/manager/src/main/java/com/example/cloud/iot/examples/MqttExample.java +++ b/iot/api-client/manager/src/main/java/com/example/cloud/iot/examples/MqttExample.java @@ -197,6 +197,7 @@ public static void main(String[] args) throws Exception { options.messageType, i, options.numMessages, payload); // Refresh the connection credentials before the JWT expires. + // [START cloudiotcore_mqtt_jwt_refresh] long secsSinceRefresh = ((new DateTime()).getMillis() - iat.getMillis()) / 1000; if (secsSinceRefresh > (options.tokenExpMins * 60)) { System.out.format("\tRefreshing token after: %d seconds\n", secsSinceRefresh); @@ -216,6 +217,7 @@ public static void main(String[] args) throws Exception { client.connect(); attachCallback(client, options.deviceId); } + // [END cloudiotcore_mqtt_jwt_refresh] // Publish "payload" to the MQTT topic. qos=1 means at least once delivery. Cloud IoT Core // also supports qos=0 for at most once delivery.