[Feature] Add token exchange auth strategy and hooks support to shopify-app-express#3097
Open
mrmarufpro wants to merge 2 commits intoShopify:mainfrom
Open
[Feature] Add token exchange auth strategy and hooks support to shopify-app-express#3097mrmarufpro wants to merge 2 commits intoShopify:mainfrom
mrmarufpro wants to merge 2 commits intoShopify:mainfrom
Conversation
Author
|
I've been running these changes in a production embedded app by patching the package locally, and everything is working as expected. Token exchange flows complete cleanly, I did need a couple of minor tweaks to get it wired up in my app, but nothing that points to a problem with the implementation itself — just the usual integration details. Overall the behavior is solid and consistent with how the Remix package handles token exchange. Happy to share more specifics if it helps the review. |
Author
|
Hi @lizkenyon, I’m requesting a review. |
… support Implements the `unstable_newEmbeddedAuthStrategy` future flag which enables token exchange-based authentication for embedded apps, bypassing the OAuth redirect flow when a Bearer session token is present. Also adds: - `future` config option with feature flag support and logging - `hooks.afterAuth` callback invoked after OAuth and token exchange flows - `registerWebhooks` convenience method on the ShopifyApp object - `idempotentPromiseHandler` to deduplicate concurrent hook invocations - `expiring` offline access token support in auth callback and token exchange - `ensureOfflineTokenIsNotExpired` helper to refresh tokens nearing expiry Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
WHY are these changes introduced?
Fixes #630 — adds token exchange authentication support to
shopify-app-express, bringing it to parity with the Remix package.Shopify's token exchange API reduces flickering and OAuth redirects for embedded apps. While this was already supported in the Remix package, Express apps had no way to use it. This PR implements token exchange for Express behind the
unstable_newEmbeddedAuthStrategyfuture flag so existing apps are unaffected.WHAT is this pull request doing?
futureconfig option — adds a feature flag system (unstable_newEmbeddedAuthStrategy,expiringOfflineAccessTokens) with logging for disabled flagsperform-token-exchange.ts) — whenunstable_newEmbeddedAuthStrategyis enabled and a Bearer token is present in theAuthorizationheader,validateAuthenticatedSessionperforms a token exchange instead of redirecting to OAuthensureInstalledshortcut — when the token exchange strategy is on,ensureInstalledOnShopskips the session check and goes straight to embedding/loading the apphooks.afterAuth— async callback invoked after both OAuth and token exchange flows, deduplicated viaIdempotentPromiseHandlerto prevent double-firing on concurrent requestsregisterWebhooks({session})— convenience method onShopifyAppwrappingapi.webhooks.registerexpiringOfflineAccessTokensflag — threads the flag intoauth.callbackandauth.tokenExchangecallsensureOfflineTokenIsNotExpiredhelper — proactively refreshes offline tokens nearing expiry in the standard OAuth pathshopifyApp,validateAuthenticatedSession,auth, and a new token-exchange guide addedType of change
Checklist
pnpm changesetto create a draft changelog entry (do NOT update theCHANGELOG.mdfiles manually)