-
Notifications
You must be signed in to change notification settings - Fork 102
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
App Management API authentication #3834
Conversation
Thanks for your contribution! Depending on what you are working on, you may want to request a review from a Shopify team:
|
Coverage report
Show files with reduced coverage 🔻
Test suite run success1633 tests passing in 763 suites. Report generated by 🧪jest coverage report action from a9fc086 |
We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset. |
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/private/node/api.d.ts@@ -1,5 +1,5 @@
import { Headers } from 'form-data';
-export type API = 'admin' | 'storefront-renderer' | 'partners' | 'business-platform';
+export type API = 'admin' | 'storefront-renderer' | 'partners' | 'business-platform' | 'app-management';
export declare const allAPIs: API[];
interface RequestOptions<T> {
request: Promise<T>;
packages/cli-kit/dist/private/node/session.d.ts@@ -21,6 +21,14 @@ interface PartnersAPIOAuthOptions {
/** List of scopes to request permissions for. */
scopes: PartnersAPIScope[];
}
+/**
+ * A scope supported by the Developer Platform API.
+ */
+type AppManagementAPIScope = 'https://api.shopify.com/auth/organization.apps.manage' | string;
+interface AppManagementAPIOauthOptions {
+ /** List of scopes to request permissions for. */
+ scopes: AppManagementAPIScope[];
+}
/**
* A scope supported by the Storefront Renderer API.
*/
@@ -44,12 +52,14 @@ export interface OAuthApplications {
storefrontRendererApi?: StorefrontRendererAPIOAuthOptions;
partnersApi?: PartnersAPIOAuthOptions;
businessPlatformApi?: BusinessPlatformAPIOAuthOptions;
+ appManagementApi?: AppManagementAPIOauthOptions;
}
export interface OAuthSession {
admin?: AdminSession;
partners?: string;
storefront?: string;
businessPlatform?: string;
+ appManagement?: string;
}
/**
* This method ensures that we have a valid session to authenticate against the given applications using the provided scopes.
packages/cli-kit/dist/public/node/session.d.ts@@ -20,6 +20,15 @@ interface EnsureAuthenticatedAdditionalOptions {
* @returns The access token for the Partners API.
*/
export declare function ensureAuthenticatedPartners(scopes?: string[], env?: NodeJS.ProcessEnv, options?: EnsureAuthenticatedAdditionalOptions): Promise<string>;
+/**
+ * Ensure that we have a valid session to access the App Management API.
+ *
+ * @param scopes - Optional array of extra scopes to authenticate with.
+ * @param env - Optional environment variables to use.
+ * @param options - Optional extra options to use.
+ * @returns The access token for the App Management API.
+ */
+export declare function ensureAuthenticatedAppManagement(scopes?: string[], env?: NodeJS.ProcessEnv, options?: EnsureAuthenticatedAdditionalOptions): Promise<string>;
/**
* Ensure that we have a valid session to access the Storefront API.
*
packages/cli-kit/dist/private/node/session/exchange.d.ts@@ -11,6 +11,7 @@ export interface ExchangeScopes {
partners: string[];
storefront: string[];
businessPlatform: string[];
+ appManagement: string[];
}
/**
* Given a valid authorization code, request an identity access token.
|
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.
Works like a charm. 🍀
Excited to have this part done!
WHY are these changes introduced?
Related to https://github.com/Shopify/develop-app-management/issues/1752
WHAT is this pull request doing?
Authenticate against App Management API when
USE_SHOPIFY_DEVELOPERS_CLIENT
is enabledHow to test your changes?
With and without
USE_SHOPIFY_DEVELOPERS_CLIENT=1
:bin/spin p shopify auth logout
bin/spin p shopify app config link --verbose
Measuring impact
How do we know this change was effective? Please choose one:
Checklist
dev
ordeploy
have been reflected in the internal flowchart.