Skip to content
Unexpected refresh_token in Native/Public PKCE token response without offline_access
mindelin
OP

a month ago

We used an existing Native/Public Railway OAuth application with PKCE (S256).

The authorization request used:

  • response_type=code
  • scope=openid project:viewer
  • prompt=consent

The consent screen displayed only the requested permissions and confirmed one selected project.

No PAR request and no OAuth helper/library were used to construct the authorization request.

We exchanged the authorization code as a public client using the PKCE verifier and did not send a client secret.

The token endpoint returned HTTP 200.

Our non-secret diagnostics confirmed that the response included:

  • an access token
  • Bearer token type
  • expiry
  • an ID token
  • a scope matching openid project:viewer
  • a refresh_token

We only detected the presence of the refresh_token. We did not log, retain, display, or use its value.

Our local strict validator rejected the response because a refresh_token was present even though offline_access was not requested or consented to.

We did not retain or use any access or refresh token, and we revoked the OAuth grant after validation failed.

Railway's Scopes & User Consent documentation states that offline_access, combined with prompt=consent, grants refresh tokens.

The OAuth Troubleshooting documentation also states that both are required to obtain a refresh token.

Could you confirm:

  1. Is returning a refresh_token expected when offline_access was not requested or consented to?

  2. Can Railway issue refresh tokens by default for Native/Public PKCE clients independently of the requested scopes?

  3. In this situation, should the token response's scope field be treated as the authoritative granted scope?

  4. What is the recommended secure client behavior when a token response contains an unrequested refresh_token?

    • Reject the entire token response?
    • Ignore/discard the refresh_token and accept the access token?
    • Use another validation rule recommended by Railway?
  5. Is this behavior currently documented elsewhere or considered expected platform behavior?

We can provide the approximate transaction time, OAuth application identifier, and other non-secret request metadata if needed.

For security reasons, we will not provide authorization codes, PKCE verifiers, access token values, refresh token values, or client secrets.

Solved

1 Reply

Status changed to Awaiting Railway Response Railway • about 1 month ago


a month ago

Yes, this is expected behavior. We issue refresh tokens to clients that complete consent based on our own server policy, not on whether offline_access was requested, and this applies to native/public PKCE clients too. This differs from the OIDC Core convention that our Scopes & User Consent and Troubleshooting pages describe, so those pages are stricter than what the server actually does.

The scope field in the token response is the authoritative granted scope. It reflects the scopes that were requested and consented to (here openid project:viewer). The refresh token carries those same scopes and does not grant anything extra. For public clients it lasts up to 90 days, rotates on every use, and reusing a refresh token that was already consumed revokes the grant.

How your client handles it is up to you. If it has no use for long-lived access, discarding the refresh token without storing it and accepting the access token is a reasonable choice. Rejecting the whole response would make the flow fail every time, because the server will keep including a refresh token. If you discard it, revoking the grant when you finish, as you already did, stops anything from being refreshed later.


Status changed to Awaiting User Response brody • about 1 month ago


Railway
BOT

a month ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway • about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...