GCP - 检索云作曲家代理 url - 抛出错误 Expected OAuth 2 access token
GCP - retrieve cloud composer proxy url - throws error Expected OAuth 2 access toke
我正在尝试让云作曲家代理 url 从云功能中触发 dags。我正在关注下面的博客。但是在检索此 url.
时失败
命令
curl -s -H "Authorization: Bearer `gcloud auth application-default print-access-token`" https://composer.googleapis.com/v1/projects/test/locations/us-east1/environments/test-environment
我尝试了 gcloud auth print-access-token
但同样的错误
错误
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"method": "google.cloud.orchestration.airflow.service.v1.Environments.GetEnvironment",
"service": "composer.googleapis.com"
}
}
]
}
}
我关注了您分享的媒介post。注意(其中 my_project_id 是,您必须设置您的项目 ID)。
首先我创建了项目(我的用户在项目中具有所有者角色)和环境。
export GOOGLE_PROJECT_ID=`gcloud config get-value core/project`
export PROJECT_NUMBER=`gcloud projects describe my_project_id --format='value(projectNumber)'
gcloud composer environments create composer1 --location us-central1
gcloud composer environments list --locations us-central1
完成这些步骤后,我没有配置 requirements.txt
。但是我配置了连接。
gcloud composer environments update composer1 \
--update-env-variables=AIRFLOW_CONN_MY_GCF_CONN=https://us-central1-my_project_id.cloudfunctions.net --location us-central1
gcloud composer environments describe composer1 --location us-central1
gcloud composer environments describe composer1 --location us-central1 --format="get(config.dagGcsPrefix)"
然后我转到 Composer 并手动设置 python 包。
您必须单击 EDIT
并添加包的名称。
安装包后,您需要知道您是否有权访问您的令牌。 这是一些 documentation on how to create the a service account. Then you need to set your credential in the terminal,command prompt or shell that you are using. And here is some documentation on how to obtain the access token。您需要有一个服务帐户才能拥有令牌。
然后我执行第 3 步,它给您带来一条错误消息。
curl -s -H "Authorization: Bearer `gcloud auth print-access-token`" https://composer.googleapis.com/v1beta1/projects/my_project_id/locations/us-central1/environments/composer1 | jq [.config.airflowUri]
这给我带来了,我的 URL 气流看起来像:
[
"https://url-tp.appspot.com"
]
我正在尝试让云作曲家代理 url 从云功能中触发 dags。我正在关注下面的博客。但是在检索此 url.
时失败命令
curl -s -H "Authorization: Bearer `gcloud auth application-default print-access-token`" https://composer.googleapis.com/v1/projects/test/locations/us-east1/environments/test-environment
我尝试了 gcloud auth print-access-token
但同样的错误
错误
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"method": "google.cloud.orchestration.airflow.service.v1.Environments.GetEnvironment",
"service": "composer.googleapis.com"
}
}
]
}
}
我关注了您分享的媒介post。注意(其中 my_project_id 是,您必须设置您的项目 ID)。
首先我创建了项目(我的用户在项目中具有所有者角色)和环境。
export GOOGLE_PROJECT_ID=`gcloud config get-value core/project`
export PROJECT_NUMBER=`gcloud projects describe my_project_id --format='value(projectNumber)'
gcloud composer environments create composer1 --location us-central1
gcloud composer environments list --locations us-central1
完成这些步骤后,我没有配置 requirements.txt
。但是我配置了连接。
gcloud composer environments update composer1 \
--update-env-variables=AIRFLOW_CONN_MY_GCF_CONN=https://us-central1-my_project_id.cloudfunctions.net --location us-central1
gcloud composer environments describe composer1 --location us-central1
gcloud composer environments describe composer1 --location us-central1 --format="get(config.dagGcsPrefix)"
然后我转到 Composer 并手动设置 python 包。
您必须单击 EDIT
并添加包的名称。
安装包后,您需要知道您是否有权访问您的令牌。 这是一些 documentation on how to create the a service account. Then you need to set your credential in the terminal,command prompt or shell that you are using. And here is some documentation on how to obtain the access token。您需要有一个服务帐户才能拥有令牌。
然后我执行第 3 步,它给您带来一条错误消息。
curl -s -H "Authorization: Bearer `gcloud auth print-access-token`" https://composer.googleapis.com/v1beta1/projects/my_project_id/locations/us-central1/environments/composer1 | jq [.config.airflowUri]
这给我带来了,我的 URL 气流看起来像:
[
"https://url-tp.appspot.com"
]