fix(fetch): add --identity-name option for custom credential lookup#774
Merged
aidandaly24 merged 1 commit intoaws:mainfrom Apr 6, 2026
Merged
Conversation
…ws#715) The `fetch access` command hardcoded credential lookup to `<name>-oauth` via `computeManagedOAuthCredentialName()`, causing failures when users create identities with custom names. This adds an `--identity-name` option that lets users specify which credential to use for OAuth token fetch, falling back to the default convention when omitted. When no matching credential is found, the error message now lists all available OAuth credentials and suggests using `--identity-name`. Constraint: Must remain backward compatible — omitting --identity-name preserves existing behavior Rejected: Modify computeManagedOAuthCredentialName globally | would break other consumers Confidence: high Scope-risk: narrow Not-tested: TUI interactive flow and invoke command auto-fetch paths (noted as follow-up)
Contributor
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-774-tarball/aws-agentcore-0.6.0.tgz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
fetch accesscommand hardcodes credential lookup to<name>-oauthviacomputeManagedOAuthCredentialName(), causing failures when users create identities with custom names (e.g.my-custom-identityinstead ofmyGateway-oauth).This PR adds an
--identity-name <name>option tofetch accessthat lets users specify which OAuth credential to use for token fetch, falling back to the default<name>-oauthconvention when omitted. The error message when no credential is found now lists all available OAuth credentials and suggests--identity-name.Changes:
types.ts— AddedidentityName?: stringtoFetchAccessOptionscommand.tsx— Registered--identity-name <name>CLI optionaction.ts— PassidentityNamethrough tofetchGatewayTokenandfetchRuntimeTokenoauth-token.ts— Accept optionalcredentialNameparam with nullish coalescing fallback; improved error message listing available credentialsfetch-gateway-token.ts— ForwardidentityNameascredentialNamefetch-runtime-token.ts— ForwardidentityNamein bothfetchRuntimeTokenandcanFetchRuntimeTokenRelated Issue
Closes #715
Documentation PR
N/A — CLI
--helpoutput is auto-generated from the option registration.Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsUnit tests added:
fetchGatewayTokenwithidentityName)<name>-oauthconvention whenidentityNameomitted--identity-nameflag--identity-namepropagates tofetchGatewayTokenE2E verification:
agentcore deploy)agentcore fetch access --name travelgateway --identity-name my-cognito-identity --jsonreturns a valid JWT token--identity-namepreserves backward-compatible behaviorChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.