Вы, вероятно, захотите использовать
gcloud auth application-default login
gcloud auth application-default print-access-token
вместо gcloud auth login
.
Но если вы используете учетные данные gcloud (не по умолчанию для приложения), обратите внимание, что
gcloud auth login
это интерактивная команда. Вы выбираете пользователя для входа в систему, как в браузере, а не в командной строке.
Вы можете предварительно войти в систему, а затем использовать желаемые учетные данные. Например:
gcloud auth login --account [email protected]
gcloud auth login --account [email protected]
это добавляет учетные данные в хранилище учетных данных (обратите внимание, что здесь --account
используется только для проверки, чтобы убедиться, что выбранная учетная запись веб-потока такая же, как запрошенная здесь). Вы можете увидеть все доступные учетные данные, запустив
gcloud auth list
Затем вы можете использовать конкретную учетную запись по запросу.
gcloud auth print-access-token --account [email protected]
gcloud auth print-access-token --account [email protected]
Обратите внимание, что print-access-token - это недокументированная команда, и вы должны использовать ее только для отладки.
Несколько более продвинутая функция - использовать конфигурации
gcloud config configurations list
Вы можете создавать новые
gcloud config configurations create A
gcloud config set account [email protected]
gcloud config set project project_A
gcloud config configurations create B
gcloud config set account [email protected]
gcloud config set project project_B
тогда ты можешь сделать
gcloud auth print-access-token --configuration A
gcloud auth print-access-token --configuration B
дополнительное преимущество, заключающееся в том, что вы можете настраивать не только учетную запись, но и другие атрибуты, такие как проект, вычислительная зона и т. д.
person
cherba
schedule
06.04.2017