[英]how to obtain google user credentials
i need to obtain google user credentials using gcloud cli command and gcloud sdk.我需要使用 gcloud cli 命令和 gcloud sdk 获取 google 用户凭据。
obtain google user credentials process which includes ->获取 google 用户凭据过程,其中包括 ->
I need to implement above process using script.我需要使用脚本来实现上述过程。 -please help me if anyone knows documentation or any tutorial link for above process. - 如果有人知道上述过程的文档或任何教程链接,请帮助我。
It's considered bad form to ask questions without including details of an attempt to solve the problem for yourself.在不包括尝试为自己解决问题的细节的情况下提出问题被认为是一种不好的形式。 I'm assuming good faith and that you're genuinely unable to find documentation for this.我假设你是真诚的,你真的无法找到这方面的文件。 Your question is more about writing shell scripts than a specific issue with gcloud
.您的问题更多是关于编写 shell 脚本,而不是gcloud
的特定问题。
If you're using bash something of the form:如果您使用 bash 的形式:
# Variables
BILLING=[YOUR-BILLING-ID]
PROJECT=[YOUR-PROJECT-ID]
SERVICES=(
"vision"
...
)
ACCOUNT=[YOUR-ACCOUNT-NAME]
# See: https://cloud.google.com/iam/docs/understanding-roles
ROLE=[GOOGLE-IAM-ROLE]
# Create Google Cloud Project
gcloud projects create ${PROJECT}
# Link the Project with a Billing Account
gcloud beta billing projects link ${PROJECT} \
--billing-account=${BILLING}
# Enable Google services
for SERVICE in "${SERVICES[@]}"
do
gcloud services enable ${SERVICE}.googleapis.com \
--project=${PROJECT}
done
# Create a Service Account
gcloud iam service-accounts create ${ACCOUNT} \
--project=${PROJECT}
EMAIL=${ACCOUNT}@${PROJECT}.iam.gserviceaccount.com
# Create a Service Account Key
# This is generally discouraged as Keys increase security risk
gcloud iam service-accounts keys create ${PWD}/${ACCOUNT}.json \
--project=${PROJECT}
# Revise the Project's (!) IAM policy
# Permit the Service Account
# To use the Role
gcloud projects add-iam-policy-binding ${PROJECT} \
--role=${ROLE} \
--member=serviceAccount:${EMAIL}
# Optional: Application Default Credentials
export GOOGLE_APPLICATION_CREDENTIALS=${PWD}/${ACCOUNT}.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.