Skip to content

fix 'Refresh failed: Invalid token provided' caused by token-fresher request to wrong idc - #118

Open
CavemanIV wants to merge 1 commit into
tickernelz:masterfrom
CavemanIV:fix-invalid-fresh-token-provided
Open

fix 'Refresh failed: Invalid token provided' caused by token-fresher request to wrong idc#118
CavemanIV wants to merge 1 commit into
tickernelz:masterfrom
CavemanIV:fix-invalid-fresh-token-provided

Conversation

@CavemanIV

Copy link
Copy Markdown

User may experience frequently error if they use non US access point.

An IdC account has two regions and they are not always the same: the OIDC
region that issued the SSO session and refresh token, and the service
region where the CodeWhisperer profile lives. The sync layer set both to
the profile ARN's region, discarding the real OIDC region:

    const serviceRegion = extractRegionFromArn(profileArn) || ...
    const oidcRegion = serviceRegion

Since token.ts resolves auth.oidcRegion || auth.region to build the
refresh URL, every refresh for such an account went to the wrong endpoint
and failed deterministically.

Confirmed by probing both endpoints with the account's real credentials:
POST oidc.ap-southeast-1.amazonaws.com/token -> 200, expiresIn 3600
POST oidc.us-east-1.amazonaws.com/token
-> 400 invalid_request / "Invalid token provided"

The observed case is an ap-southeast-1 session paired with a us-east-1
profile ARN. The DB schema already had separate region/oidc_region
columns and token.ts already preferred oidcRegion, so only the sync layer
needed fixing.

…request to wrong idc if serviceRegion is not same with ARN region
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.

1 participant