Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我正试图在GitLab中使用google服务帐户自动收集邮差。如何验证服务帐户并发送请求?_Gitlab_Postman_Gcloud_Google Cloud Pubsub_Service Accounts - Fatal编程技术网

我正试图在GitLab中使用google服务帐户自动收集邮差。如何验证服务帐户并发送请求?

我正试图在GitLab中使用google服务帐户自动收集邮差。如何验证服务帐户并发送请求?,gitlab,postman,gcloud,google-cloud-pubsub,service-accounts,Gitlab,Postman,Gcloud,Google Cloud Pubsub,Service Accounts,背景: 我有一个GooglePub/sub主题,我可以使用Postman发布到它。我想将此postman集合放入GitLab,并使用gcloud服务帐户运行集合,而无需任何手动干预(例如,必须生成承载令牌并复制到postman集合中) 问题: 我的开发人员为一个服务帐户创建并提供了一个.JSON密钥文件(下面的屏幕截图),该帐户有权向我的主题发布消息 我遇到了一个路障,我不知道如何将来自bash的不记名代币传递到我的收藏中。到目前为止,GitLab中的.yaml文件就是这样的: stages:

背景: 我有一个GooglePub/sub主题,我可以使用Postman发布到它。我想将此postman集合放入GitLab,并使用gcloud服务帐户运行集合,而无需任何手动干预(例如,必须生成承载令牌并复制到postman集合中)

问题: 我的开发人员为一个服务帐户创建并提供了一个.JSON密钥文件(下面的屏幕截图),该帐户有权向我的主题发布消息

我遇到了一个路障,我不知道如何将来自bash的不记名代币传递到我的收藏中。到目前为止,GitLab中的.yaml文件就是这样的:

stages:
    - test

postman_tests:
    stage: test
    image: 
        name: postman/newman_alpine33
        entrypoint: [""]
    script:
        - newman --version
        - npm config set unsafe-perm true
        - GOOGLE_APPLICATION_CREDENTIALS=~/path-to-my-serviceaccount-key.json gcloud auth application-default print-access-token
        - newman run name-of-my-collection.json -e name-of-my-postman-environment.json

GOOGLE\u APPLICATION\u CREDENTIALS=~/path-to-my-serviceaccount-key.json gcloud auth应用程序默认打印访问令牌
打印出一个令牌,但我不知道如何将其传递给集合。我这样做对吗?

我认为您可以使用以下代码:

gcloud auth activate-service-account --key-file=KEY_FILE
之后,您可以使用以下方式打印您的身份令牌:

gcloud auth print-identity-token 
之后,将其作为身份验证标头传递:

curl -H "Authorization: bearer $(gcloud auth print-identity-token)" <your usual curl params>
curl-H“授权:持票人$(gcloud auth打印身份令牌)”
希望这有帮助


  • 我认为您可以使用以下代码:

    gcloud auth activate-service-account --key-file=KEY_FILE
    
    之后,您可以使用以下方式打印您的身份令牌:

    gcloud auth print-identity-token 
    
    之后,将其作为身份验证标头传递:

    curl -H "Authorization: bearer $(gcloud auth print-identity-token)" <your usual curl params>
    
    curl-H“授权:持票人$(gcloud auth打印身份令牌)”
    
    希望这有帮助


  • 我不熟悉postman | newman,但就我所知,
    GOOGLE|u APPLICATION_CREDENTIALS
    是一个仅由GOOGLE SDK使用的环境变量,这不是postman所期望的。您生成的承载令牌必须以某种方式通过标头提供给Postman API调用。。。curl的等价物是
    curl--标头“授权:承载${Time}”/代码>,您将需要一些类似的BTW,因为您正在安装(??)代码> GMule<代码>到容器中,您可能需要考虑。这是一个Google实用程序,您可以使用它更直接地从服务帐户凭据中获取凭据。我不熟悉postman | newman,但
    Google|u应用程序(u credentials
    是一个环境变量(据我所知)仅由Google SDK使用,这不是postman所期望的。您生成的承载令牌必须以某种方式通过标头提供给Postman API调用。。。curl的等价物是
    curl--标头“授权:承载${Time}”/代码>,您将需要一些类似的BTW,因为您正在安装(??)代码> GMule<代码>到容器中,您可能需要考虑。这是一个Google实用程序,您可以使用它更直接地从服务帐户中获取凭据。