-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh theme auth #3375
Refresh theme auth #3375
Conversation
We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset. |
Coverage report
Show files with reduced coverage 🔻
Test suite run success1602 tests passing in 746 suites. Report generated by 🧪jest coverage report action from 0e156f0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @amcaplan! LGTM and it works as expected* as well! 🚀 I believe we only need to fix the minor lint error in the CI, and then we will be ready to merge!
-
* In my tests, I noticed that the token we're setting via theme token
is equal to the old one. However, because ensureAuthenticatedPartners
is widely used, I assume that it sometimes returns the same token because it's still valid.
-
Update: I left my development server running for some hours, and it really refreshes the token 🚀
1db89fa
to
0e156f0
Compare
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/session.d.ts@@ -6,7 +6,7 @@ export interface AdminSession {
token: string;
storeFqdn: string;
}
-interface EnsureAuthenticatedPartnersOptions {
+interface EnsureAuthenticatedAdditionalOptions {
noPrompt?: boolean;
}
/**
@@ -19,7 +19,7 @@ interface EnsureAuthenticatedPartnersOptions {
* @param options - Optional extra options to use.
* @returns The access token for the Partners API.
*/
-export declare function ensureAuthenticatedPartners(scopes?: string[], env?: NodeJS.ProcessEnv, options?: EnsureAuthenticatedPartnersOptions): Promise<string>;
+export declare function ensureAuthenticatedPartners(scopes?: string[], env?: NodeJS.ProcessEnv, options?: EnsureAuthenticatedAdditionalOptions): Promise<string>;
/**
* Ensure that we have a valid session to access the Storefront API.
*
@@ -35,9 +35,10 @@ export declare function ensureAuthenticatedStorefront(scopes?: string[], passwor
* @param store - Store fqdn to request auth for.
* @param scopes - Optional array of extra scopes to authenticate with.
* @param forceRefresh - Optional flag to force a refresh of the token.
+ * @param options - Optional extra options to use.
* @returns The access token for the Admin API.
*/
-export declare function ensureAuthenticatedAdmin(store: string, scopes?: string[], forceRefresh?: boolean): Promise<AdminSession>;
+export declare function ensureAuthenticatedAdmin(store: string, scopes?: string[], forceRefresh?: boolean, options?: EnsureAuthenticatedAdditionalOptions): Promise<AdminSession>;
/**
* Ensure that we have a valid session to access the Theme API.
* If a password is provided, that token will be used against Theme Access API.
|
@karreiro your instincts are correct! We will get the same token string until it expires. |
WHY are these changes introduced?
Fixes #3173
Pushing Theme App Extension drafts requires unexpired Partners auth. Unfortunately, given the Ruby subprocess system we live with (for now), nothing is refreshing authentication, so sometime within ~2 hours the authentication expires, and the theme app extension silently stops reloading on save.
WHAT is this pull request doing?
theme token
command to pass a Partners token and save in the localShopify::DB
. That token is utilized by theextension serve
process because we no longer pass atoken
flag.theme extension serve
is called, and refreshed again every 3 minutes.dev
process, because we don't want to pretend things are still working when they aren't.Note this means that if the internet connection is down for a few minutes,
dev
will crash rather than recovering smoothly when the connection is restored. I'm not sure whether that's a concern or not.How to test your changes?
dev
on an app with a Theme App Extensionshopify app dev
stops authenticating development store preview #3173 no longer happens, instead the TAE updates successfully.Measuring impact
How do we know this change was effective? Please choose one:
Checklist
dev
ordeploy
have been reflected in the internal flowchart.