xref: /aosp_15_r20/external/cronet/build/fuchsia/get_auth_token.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/usr/bin/env vpython3
2# Copyright 2023 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Print the default service account's auth token to stdout."""
6
7from __future__ import absolute_import
8import os
9import subprocess
10import sys
11
12sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
13                                             'test')))
14from common import DIR_SRC_ROOT
15
16sys.path.append(os.path.join(DIR_SRC_ROOT, 'build'))
17import find_depot_tools
18
19
20def main():
21  luci_auth = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'luci-auth')
22  proc = subprocess.run([
23      luci_auth, 'token', '-scopes',
24      'https://www.googleapis.com/auth/devstorage.read_only'
25  ],
26                        encoding='utf-8')
27  return proc.returncode
28
29
30if __name__ == '__main__':
31  sys.exit(main())
32