Revert "Upload metrics in test runner"

This reverts commit deea9b84da57629ca67c5a45a020d38eba5659ab.

Reason for revert: breaking the tree

Original change's description:
> Upload metrics in test runner
>
> This is a reland of https://flutter-review.googlesource.com/c/recipes/+/17200.
> Changes:
> 1) addressed null result data case: https://github.com/flutter/flutter/pull/88749
> 2) separate gcs and cocoon token
> 3) add token util as a module so that engine and devicelab drone can share
>
> Example led run: https://logs.chromium.org/logs/flutter/led/keyonghan_google.com/497ab131c93e471b033ee24db06b3c034376ea3ccf38e738ed71b2c665d92257/+/u/Upload_metrics/upload_results/stdout (ignore the http error, as this is testing againt a non-prod commit which doesn't exist in cocoon).
>
> Change-Id: I76d3f68c5e07aec99427b3c2a631812d8453e4ce
> Bug: https://github.com/flutter/flutter/issues/88484
> Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/17343
> Reviewed-by: Casey Hillers <chillers@google.com>
> Commit-Queue: Keyong Han <keyonghan@google.com>

TBR=godofredoc@google.com,keyonghan@google.com,chillers@google.com,flutter-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Idfa2db8aac17530b87f0df741bebd466cc7c328c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/flutter/flutter/issues/88484
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/17380
Reviewed-by: Keyong Han <keyonghan@google.com>
Commit-Queue: Keyong Han <keyonghan@google.com>
diff --git a/recipe_modules/token_util/__init__.py b/recipe_modules/token_util/__init__.py
deleted file mode 100644
index 79334ab..0000000
--- a/recipe_modules/token_util/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-DEPS = [
-    'recipe_engine/file',
-    'recipe_engine/path',
-    'recipe_engine/service_account',
-    "recipe_engine/step",
-]
diff --git a/recipe_modules/token_util/api.py b/recipe_modules/token_util/api.py
deleted file mode 100644
index facb840..0000000
--- a/recipe_modules/token_util/api.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2020 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from recipe_engine import recipe_api
-
-
-class TokenUtilApi(recipe_api.RecipeApi):
-  """Utilities to generate tokens for communicating data."""
-
-  def metric_center_token(self):
-    """Generate a token to interact with GCS.
-
-    Returns the path to the written token.
-    """
-    service_account = self.m.service_account.default()
-    metrics_center_access_token = service_account.get_access_token(
-        scopes=[
-            'https://www.googleapis.com/auth/cloud-platform',
-            'https://www.googleapis.com/auth/datastore'
-        ]
-    )
-    metrics_center_token_path = self.m.path.mkstemp()
-    self.m.file.write_text(
-        "write metric center token",
-        metrics_center_token_path,
-        metrics_center_access_token,
-        include_log=False
-    )
-    return metrics_center_token_path
-
-  def cocoon_token(self):
-    """Generate a token to interact with Cocoon backend APIs.
-
-    Returns the path to the written token.
-    """
-    service_account = self.m.service_account.default()
-    cocoon_access_token = service_account.get_access_token()
-
-    cocoon_access_token_path = self.m.path.mkstemp()
-    self.m.file.write_text(
-        "write cocoon token",
-        cocoon_access_token_path,
-        cocoon_access_token,
-        include_log=False
-    )
-    return cocoon_access_token_path
diff --git a/recipe_modules/token_util/examples/full.expected/basic.json b/recipe_modules/token_util/examples/full.expected/basic.json
deleted file mode 100644
index 89c9607..0000000
--- a/recipe_modules/token_util/examples/full.expected/basic.json
+++ /dev/null
@@ -1,55 +0,0 @@
-[
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-scopes",
-      "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore",
-      "-lifetime",
-      "3m"
-    ],
-    "infra_step": true,
-    "name": "get access token for default account"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_1"
-    ],
-    "infra_step": true,
-    "name": "write metric center token"
-  },
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-lifetime",
-      "3m"
-    ],
-    "infra_step": true,
-    "name": "get access token for default account (2)"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_2"
-    ],
-    "infra_step": true,
-    "name": "write cocoon token"
-  },
-  {
-    "name": "$result"
-  }
-]
\ No newline at end of file
diff --git a/recipe_modules/token_util/examples/full.py b/recipe_modules/token_util/examples/full.py
deleted file mode 100644
index 53afcbe..0000000
--- a/recipe_modules/token_util/examples/full.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2020 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from recipe_engine.recipe_api import Property
-
-DEPS = [
-    'flutter/token_util',
-]
-
-
-def RunSteps(api):
-  api.token_util.metric_center_token()
-  api.token_util.cocoon_token()
-
-
-def GenTests(api):
-  yield api.test('basic')
diff --git a/recipes/devicelab/devicelab_drone.expected/basic.json b/recipes/devicelab/devicelab_drone.expected/basic.json
index d96a541..0116e98 100644
--- a/recipes/devicelab/devicelab_drone.expected/basic.json
+++ b/recipes/devicelab/devicelab_drone.expected/basic.json
@@ -110,17 +110,6 @@
     ]
   },
   {
-    "cmd": [
-      "git",
-      "log",
-      "--pretty=format:%ct",
-      "-n",
-      "1"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-    "name": "git commit time"
-  },
-  {
     "cmd": [],
     "name": "Initialize logs"
   },
diff --git a/recipes/devicelab/devicelab_drone.expected/local-engine.json b/recipes/devicelab/devicelab_drone.expected/local-engine.json
index c68ad6d..9e45a30 100644
--- a/recipes/devicelab/devicelab_drone.expected/local-engine.json
+++ b/recipes/devicelab/devicelab_drone.expected/local-engine.json
@@ -110,17 +110,6 @@
     ]
   },
   {
-    "cmd": [
-      "git",
-      "log",
-      "--pretty=format:%ct",
-      "-n",
-      "1"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-    "name": "git commit time"
-  },
-  {
     "cmd": [],
     "name": "Initialize logs"
   },
@@ -762,8 +751,6 @@
     "cmd": [
       "luci-auth",
       "token",
-      "-scopes",
-      "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore",
       "-lifetime",
       "3m"
     ],
@@ -827,79 +814,7 @@
       ]
     },
     "infra_step": true,
-    "name": "Upload metrics.write metric center token",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-lifetime",
-      "3m"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LOCAL_ENGINE": "[CLEANUP]/builder/src/out/host-release",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/builder/src/out/host-release/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.get access token for default account (2)",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_4"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LOCAL_ENGINE": "[CLEANUP]/builder/src/out/host-release",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/builder/src/out/host-release/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.write cocoon token",
+    "name": "Upload metrics.write token",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -918,32 +833,26 @@
       "--test-status",
       "Succeeded",
       "--service-account-token-file",
-      "[CLEANUP]/tmp_tmp_4"
+      "[CLEANUP]/tmp_tmp_3"
     ],
     "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
       "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
       "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GCP_PROJECT": "flutter-infra",
       "LOCAL_ENGINE": "[CLEANUP]/builder/src/out/host-release",
       "LUCI_BRANCH": "",
       "LUCI_CI": "True",
       "LUCI_PR": "",
       "OS": "linux",
       "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_3"
+      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
     },
     "env_prefixes": {
       "PATH": [
         "[CLEANUP]/builder/src/out/host-release/dart-sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
-        "[CLEANUP]/builder/src/out/host-release/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
         "[CLEANUP]/tmp_tmp_2/vpython"
       ]
     },
diff --git a/recipes/devicelab/devicelab_drone.expected/no-task-name.json b/recipes/devicelab/devicelab_drone.expected/no-task-name.json
index abdcd25..286b5f6 100644
--- a/recipes/devicelab/devicelab_drone.expected/no-task-name.json
+++ b/recipes/devicelab/devicelab_drone.expected/no-task-name.json
@@ -7,7 +7,7 @@
       "The recipe has crashed at point 'Uncaught exception'!",
       "",
       "Traceback (most recent call last):",
-      "  File \"RECIPE_REPO[flutter]/recipes/devicelab/devicelab_drone.py\", line 40, in RunSteps",
+      "  File \"RECIPE_REPO[flutter]/recipes/devicelab/devicelab_drone.py\", line 38, in RunSteps",
       "    raise ValueError('A task_name property is required')",
       "ValueError: A task_name property is required"
     ]
diff --git a/recipes/devicelab/devicelab_drone.expected/post-submit.json b/recipes/devicelab/devicelab_drone.expected/post-submit.json
index 3f8470d..4f91cd8 100644
--- a/recipes/devicelab/devicelab_drone.expected/post-submit.json
+++ b/recipes/devicelab/devicelab_drone.expected/post-submit.json
@@ -118,17 +118,6 @@
     ]
   },
   {
-    "cmd": [
-      "git",
-      "log",
-      "--pretty=format:%ct",
-      "-n",
-      "1"
-    ],
-    "cwd": "[CLEANUP]\\tmp_tmp_1\\flutter sdk",
-    "name": "git commit time"
-  },
-  {
     "cmd": [],
     "name": "Initialize logs"
   },
@@ -650,8 +639,6 @@
     "cmd": [
       "luci-auth",
       "token",
-      "-scopes",
-      "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore",
       "-lifetime",
       "3m"
     ],
@@ -711,75 +698,7 @@
       ]
     },
     "infra_step": true,
-    "name": "Upload metrics.write metric center token",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-lifetime",
-      "3m"
-    ],
-    "cwd": "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\dev\\devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]\\flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]\\flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "win",
-      "PUB_CACHE": "[START_DIR]\\.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]\\tmp_tmp_1\\flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin",
-        "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin\\cache\\dart-sdk\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.get access token for default account (2)",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]\\resources\\fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]\\tmp_tmp_4"
-    ],
-    "cwd": "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\dev\\devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]\\flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]\\flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "win",
-      "PUB_CACHE": "[START_DIR]\\.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]\\tmp_tmp_1\\flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin",
-        "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin\\cache\\dart-sdk\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.write cocoon token",
+    "name": "Upload metrics.write token",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -793,32 +712,25 @@
       "True",
       "--results-file",
       "[CLEANUP]\\results_tmp_1\\results",
-      "--commit-time",
-      "",
       "--service-account-token-file",
-      "[CLEANUP]\\tmp_tmp_4"
+      "[CLEANUP]\\tmp_tmp_3"
     ],
     "cwd": "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\dev\\devicelab",
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
       "FLUTTER_LOGS_DIR": "[CLEANUP]\\flutter_logs_dir",
       "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]\\flutter_logs_dir",
-      "GCP_PROJECT": "flutter-infra",
       "LUCI_BRANCH": "",
       "LUCI_CI": "True",
       "LUCI_PR": "",
       "OS": "win",
       "PUB_CACHE": "[START_DIR]\\.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]\\tmp_tmp_1\\flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]\\tmp_tmp_3"
+      "SDK_CHECKOUT_PATH": "[CLEANUP]\\tmp_tmp_1\\flutter sdk"
     },
     "env_prefixes": {
       "PATH": [
         "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin",
         "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin\\cache\\dart-sdk\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\vpython",
-        "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin",
-        "[CLEANUP]\\tmp_tmp_1\\flutter sdk\\bin\\cache\\dart-sdk\\bin",
         "[CLEANUP]\\tmp_tmp_2\\vpython"
       ]
     },
diff --git a/recipes/devicelab/devicelab_drone.expected/upload-metrics-mac.json b/recipes/devicelab/devicelab_drone.expected/upload-metrics-mac.json
index d41ece6..c2411ca 100644
--- a/recipes/devicelab/devicelab_drone.expected/upload-metrics-mac.json
+++ b/recipes/devicelab/devicelab_drone.expected/upload-metrics-mac.json
@@ -110,17 +110,6 @@
     ]
   },
   {
-    "cmd": [
-      "git",
-      "log",
-      "--pretty=format:%ct",
-      "-n",
-      "1"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-    "name": "git commit time"
-  },
-  {
     "cmd": [],
     "name": "Initialize logs"
   },
@@ -660,8 +649,6 @@
     "cmd": [
       "luci-auth",
       "token",
-      "-scopes",
-      "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore",
       "-lifetime",
       "3m"
     ],
@@ -721,75 +708,7 @@
       ]
     },
     "infra_step": true,
-    "name": "Upload metrics.write metric center token",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-lifetime",
-      "3m"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.get access token for default account (2)",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_4"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.write cocoon token",
+    "name": "Upload metrics.write token",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -803,32 +722,25 @@
       "False",
       "--results-file",
       "[CLEANUP]/results_tmp_1/results",
-      "--commit-time",
-      "",
       "--service-account-token-file",
-      "[CLEANUP]/tmp_tmp_4"
+      "[CLEANUP]/tmp_tmp_3"
     ],
     "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
       "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
       "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GCP_PROJECT": "flutter-infra",
       "LUCI_BRANCH": "",
       "LUCI_CI": "True",
       "LUCI_PR": "",
       "OS": "linux",
       "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_3"
+      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
     },
     "env_prefixes": {
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
         "[CLEANUP]/tmp_tmp_2/vpython"
       ]
     },
diff --git a/recipes/devicelab/devicelab_drone.expected/xcode-chromium-mac.json b/recipes/devicelab/devicelab_drone.expected/xcode-chromium-mac.json
index 6837a94..b5f1d8d 100644
--- a/recipes/devicelab/devicelab_drone.expected/xcode-chromium-mac.json
+++ b/recipes/devicelab/devicelab_drone.expected/xcode-chromium-mac.json
@@ -110,17 +110,6 @@
     ]
   },
   {
-    "cmd": [
-      "git",
-      "log",
-      "--pretty=format:%ct",
-      "-n",
-      "1"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-    "name": "git commit time"
-  },
-  {
     "cmd": [],
     "name": "Initialize logs"
   },
@@ -660,8 +649,6 @@
     "cmd": [
       "luci-auth",
       "token",
-      "-scopes",
-      "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore",
       "-lifetime",
       "3m"
     ],
@@ -721,75 +708,7 @@
       ]
     },
     "infra_step": true,
-    "name": "Upload metrics.write metric center token",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-lifetime",
-      "3m"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.get access token for default account (2)",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_4"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.write cocoon token",
+    "name": "Upload metrics.write token",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -808,29 +727,24 @@
       "--test-status",
       "Succeeded",
       "--service-account-token-file",
-      "[CLEANUP]/tmp_tmp_4"
+      "[CLEANUP]/tmp_tmp_3"
     ],
     "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
       "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
       "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GCP_PROJECT": "flutter-infra",
       "LUCI_BRANCH": "",
       "LUCI_CI": "True",
       "LUCI_PR": "",
       "OS": "linux",
       "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_3"
+      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
     },
     "env_prefixes": {
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
         "[CLEANUP]/tmp_tmp_2/vpython"
       ]
     },
diff --git a/recipes/devicelab/devicelab_drone.expected/xcode-devicelab.json b/recipes/devicelab/devicelab_drone.expected/xcode-devicelab.json
index 5ac1e9e..4da7978 100644
--- a/recipes/devicelab/devicelab_drone.expected/xcode-devicelab.json
+++ b/recipes/devicelab/devicelab_drone.expected/xcode-devicelab.json
@@ -110,17 +110,6 @@
     ]
   },
   {
-    "cmd": [
-      "git",
-      "log",
-      "--pretty=format:%ct",
-      "-n",
-      "1"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-    "name": "git commit time"
-  },
-  {
     "cmd": [],
     "name": "Initialize logs"
   },
@@ -692,8 +681,6 @@
     "cmd": [
       "luci-auth",
       "token",
-      "-scopes",
-      "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore",
       "-lifetime",
       "3m"
     ],
@@ -753,75 +740,7 @@
       ]
     },
     "infra_step": true,
-    "name": "Upload metrics.write metric center token",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "luci-auth",
-      "token",
-      "-lifetime",
-      "3m"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.get access token for default account (2)",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_4"
-    ],
-    "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
-      ]
-    },
-    "infra_step": true,
-    "name": "Upload metrics.write cocoon token",
+    "name": "Upload metrics.write token",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -840,29 +759,24 @@
       "--test-status",
       "Succeeded",
       "--service-account-token-file",
-      "[CLEANUP]/tmp_tmp_4"
+      "[CLEANUP]/tmp_tmp_3"
     ],
     "cwd": "[CLEANUP]/tmp_tmp_1/flutter sdk/dev/devicelab",
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
       "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
       "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GCP_PROJECT": "flutter-infra",
       "LUCI_BRANCH": "",
       "LUCI_CI": "True",
       "LUCI_PR": "",
       "OS": "linux",
       "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_3"
+      "SDK_CHECKOUT_PATH": "[CLEANUP]/tmp_tmp_1/flutter sdk"
     },
     "env_prefixes": {
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
-        "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
         "[CLEANUP]/tmp_tmp_2/vpython"
       ]
     },
diff --git a/recipes/devicelab/devicelab_drone.py b/recipes/devicelab/devicelab_drone.py
index c589091..fb6147c 100644
--- a/recipes/devicelab/devicelab_drone.py
+++ b/recipes/devicelab/devicelab_drone.py
@@ -5,7 +5,6 @@
 from recipe_engine.recipe_api import Property
 
 DEPS = [
-    'fuchsia/git',
     'flutter/bucket_util',
     'flutter/devicelab_osx_sdk',
     'flutter/flutter_deps',
@@ -15,7 +14,6 @@
     'flutter/osx_sdk',
     'flutter/retry',
     'flutter/test_utils',
-    'flutter/token_util',
     'recipe_engine/buildbucket',
     'recipe_engine/cas',
     'recipe_engine/context',
@@ -48,15 +46,6 @@
       api.properties.get('git_url'),
       api.properties.get('git_ref'),
   )
-  with api.context(cwd=flutter_path):
-    commit_time = api.git(
-        'git commit time',
-        'log',
-        '--pretty=format:%ct',
-        '-n',
-        '1',
-        stdout=api.raw_io.output()
-    ).stdout.rstrip()
   env, env_prefixes = api.repo_util.flutter_environment(flutter_path)
   api.logs_util.initialize_logs_collection(env)
   with api.step.nest('Dependencies'):
@@ -128,8 +117,8 @@
           check_flaky(api)
   with api.context(env=env, env_prefixes=env_prefixes, cwd=devicelab_path):
     uploadResults(
-        api, env, env_prefixes, results_path, test_status == 'flaky',
-        git_branch, api.properties.get('buildername'), commit_time
+        api, results_path, test_status == 'flaky', git_branch,
+        api.properties.get('buildername')
     )
     uploadMetricsToCas(api, results_path)
 
@@ -189,8 +178,7 @@
   """
   supported_branches = ['master']
   if api.runtime.is_experimental or api.properties.get(
-      'git_url'
-  ) or 'staging' in builder_name or git_branch not in supported_branches:
+      'git_url') or 'staging' in builder_name or git_branch not in supported_branches:
     return True
   else:
     return False
@@ -198,14 +186,11 @@
 
 def uploadResults(
     api,
-    env,
-    env_prefixes,
     results_path,
     is_test_flaky,
     git_branch,
     builder_name,
-    commit_time,
-    test_status='Succeeded',
+    test_status='Succeeded'
 ):
   """Upload DeviceLab test results to Cocoon.
 
@@ -225,21 +210,18 @@
         '--test-status', test_status
     ])
   else:
-    runner_params.extend([
-        '--results-file', results_path, '--commit-time', commit_time
-    ])
-
+    runner_params.extend(['--results-file', results_path])
   with api.step.nest('Upload metrics'):
-    env['TOKEN_PATH'] = api.token_util.metric_center_token()
-    env['GCP_PROJECT'] = 'flutter-infra'
-    runner_params.extend([
-        '--service-account-token-file',
-        api.token_util.cocoon_token()
-    ])
+    service_account = api.service_account.default()
+    access_token = service_account.get_access_token()
+    access_token_path = api.path.mkstemp()
+    api.file.write_text(
+        "write token", access_token_path, access_token, include_log=False
+    )
+    runner_params.extend(['--service-account-token-file', access_token_path])
     upload_command = ['dart', 'bin/test_runner.dart', 'upload-metrics']
     upload_command.extend(runner_params)
-    with api.context(env=env, env_prefixes=env_prefixes):
-      api.step('upload results', upload_command, infra_step=True)
+    api.step('upload results', upload_command, infra_step=True)
 
 
 def uploadMetricsToCas(api, results_path):
@@ -285,7 +267,9 @@
           task_name='abc',
           dependencies=[{'dependency': 'xcode'}]
       ), api.repo_util.flutter_environment_data(checkout_dir=checkout_path),
-      api.buildbucket.ci_build(git_ref='refs/heads/master',),
+      api.buildbucket.ci_build(
+          git_ref='refs/heads/master',
+      ),
       api.step_data(
           'run abc',
           stdout=api.raw_io.output_text('#flaky\nthis is a flaky\nflaky: true'),
@@ -299,7 +283,9 @@
           task_name='abc',
           dependencies=[{'dependency': 'xcode'}]
       ),
-      api.buildbucket.ci_build(git_ref='refs/heads/master',),
+      api.buildbucket.ci_build(
+          git_ref='refs/heads/master',
+      ),
       api.repo_util.flutter_environment_data(checkout_dir=checkout_path),
   )
   yield api.test(
@@ -313,7 +299,9 @@
           stdout=api.raw_io.output_text('#flaky\nthis is a flaky\nflaky: true'),
           retcode=0
       ),
-      api.buildbucket.ci_build(git_ref='refs/heads/master',),
+      api.buildbucket.ci_build(
+          git_ref='refs/heads/master',
+      ),
       api.platform.name('win'),
   )
   yield api.test(
@@ -325,7 +313,9 @@
           upload_metrics=True,
           upload_metrics_to_cas=True,
       ), api.repo_util.flutter_environment_data(checkout_dir=checkout_path),
-      api.buildbucket.ci_build(git_ref='refs/heads/master',)
+      api.buildbucket.ci_build(
+          git_ref='refs/heads/master',
+      )
   )
   yield api.test(
       "local-engine",
diff --git a/recipes/engine/engine_metrics.expected/basic.json b/recipes/engine/engine_metrics.expected/basic.json
index 1706ded..26c461d 100644
--- a/recipes/engine/engine_metrics.expected/basic.json
+++ b/recipes/engine/engine_metrics.expected/basic.json
@@ -704,7 +704,7 @@
       "[CLEANUP]/tmp_tmp_1"
     ],
     "infra_step": true,
-    "name": "write metric center token"
+    "name": "write token"
   },
   {
     "cmd": [
diff --git a/recipes/engine/engine_metrics.py b/recipes/engine/engine_metrics.py
index ccdcfc6..494155f 100644
--- a/recipes/engine/engine_metrics.py
+++ b/recipes/engine/engine_metrics.py
@@ -11,7 +11,6 @@
     'flutter/build_util',
     'flutter/os_utils',
     'flutter/repo_util',
-    'flutter/token_util',
     'fuchsia/goma',
     'recipe_engine/context',
     'recipe_engine/file',
@@ -35,15 +34,14 @@
   )
   android_home = checkout_path.join('third_party', 'android_tools', 'sdk')
   env = {
-      'ANDROID_HOME': str(android_home),
-      'FLUTTER_PREBUILT_DART_SDK': 'True',
+    'ANDROID_HOME': str(android_home),
+    'FLUTTER_PREBUILT_DART_SDK': 'True',
   }
   env_prefixes = {'PATH': [dart_bin]}
   api.repo_util.engine_checkout(cache_root, env, env_prefixes)
   with api.depot_tools.on_path(), api.context(env=env,
                                               env_prefixes=env_prefixes):
-    api.build_util.run_gn(['--runtime-mode', 'release', '--prebuilt-dart-sdk'],
-                          checkout_path)
+    api.build_util.run_gn(['--runtime-mode', 'release', '--prebuilt-dart-sdk'], checkout_path)
     api.build_util.build('host_release', checkout_path, [])
 
   host_release_path = checkout_path.join('out', 'host_release')
@@ -63,7 +61,18 @@
       'flutter', 'testing', 'benchmark', 'upload_metrics.sh'
   )
 
-  env['TOKEN_PATH'] = api.token_util.metric_center_token()
+  service_account = api.service_account.default()
+  access_token = service_account.get_access_token(
+      scopes=[
+          'https://www.googleapis.com/auth/cloud-platform',
+          'https://www.googleapis.com/auth/datastore'
+      ]
+  )
+  access_token_path = api.path.mkstemp()
+  api.file.write_text(
+      'write token', access_token_path, access_token, include_log=False
+  )
+  env['TOKEN_PATH'] = access_token_path
   env['GCP_PROJECT'] = 'flutter-cirrus'
   with api.context(env=env, env_prefixes=env_prefixes, cwd=benchmark_path):
     api.step('Upload metrics', ['bash', script_path])