这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@srinandan
Copy link
Collaborator

No description provided.

@srinandan srinandan requested a review from kurtkanaskie August 11, 2023 18:31
@srinandan srinandan linked an issue Aug 11, 2023 that may be closed by this pull request
@srinandan srinandan self-assigned this Aug 11, 2023
Copy link
Collaborator

@kurtkanaskie kurtkanaskie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine in Cloud Shell and on a VM (debian).

However, in a simple Cloud Build, I get 403 error

steps:
  - name: gcr.io/cloud-builders/gcloud
    args:
      - '-c'
      - echo hello
    entrypoint: bash
  - name: 'golang:1.17.3'
    args:
      - '-c'
      - >-
        APIGEECLI_DEBUG=true go run main.go --org=apigeex-mint-kurt organizations get
        --metadata-token
    entrypoint: bash

Error:

Step #1: DEBUG: 2023/08/14 19:16:16 clifile.go:56: Cached preferences was not found
Step #1: DEBUG: 2023/08/14 19:16:16 clifile.go:151: Writing  {"lastCheck":"08-14-2023"}
Step #1: DEBUG: 2023/08/14 19:16:16 root.go:83: apigeecli wasn't built with a valid Version tag.
Step #1: DEBUG: 2023/08/14 19:16:16 token.go:279: Connecting to:  http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token
Step #1: DEBUG: 2023/08/14 19:16:16 httpclient.go:282: Connecting to:  https://apigee.googleapis.com/v1/organizations/apigeex-mint-kurt
Step #1: DEBUG: 2023/08/14 19:16:16 httpclient.go:430: Setting token :  ya29.c.b0Aaekm-REDACTED
Step #1: DEBUG: 2023/08/14 19:16:16 httpclient.go:313: Content-Type :  application/json
Step #1: DEBUG: 2023/08/14 19:16:16 httpclient.go:450: status code 403, error in response: {
Step #1:   "error": {
Step #1:     "code": 403,
Step #1:     "message": "Permission 'apigee.organizations.get' denied on resource 'organizations/apigeex-mint-kurt' (or it may not exist)",
Step #1:     "status": "PERMISSION_DENIED"
Step #1:   }
Step #1: }
Step #1: 
Step #1: {
Step #1:   "error": {
Step #1:     "code": 403,
Step #1:     "message": "Permission 'apigee.organizations.get' denied on resource 'organizations/apigeex-mint-kurt' (or it may not exist)",
Step #1:     "status": "PERMISSION_DENIED"
Step #1:   }
Step #1: }
Step #1: 
Step #1: Error: Forbidden - the client does not have access rights
Step #1: Usage:
Step #1:   apigeecli organizations get [flags]
Step #1: 
Step #1: Flags:
Step #1:   -h, --help         help for get
Step #1:   -o, --org string   Apigee organization name
Step #1: 
Step #1: Global Flags:
Step #1:   -a, --account string   Path Service Account private key in JSON
Step #1:       --disable-check    Disable check for newer versions
Step #1:       --metadata-token   Metadata OAuth2 access token
Step #1:       --no-output        Disable printing all statements to stdout
Step #1:       --print-output     Control printing of info log statements (default true)
Step #1:   -t, --token string     Google OAuth Token
Step #1: 
Step #1: exit status 1

I copied and pasted the token but it didn't work in another terminal.

@kurtkanaskie
Copy link
Collaborator

LGTM, had to add Apigee Org Admin to the $PROJNUMBER@cloudbuild.gserviceaccount.com for my project.

@srinandan srinandan merged commit 9c75e3c into main Aug 14, 2023
@srinandan srinandan deleted the issue260 branch August 14, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add support for metadata access token

3 participants