Repository navigation
Request the new RRM scopes for the express setup #13004
Description
Feature Description
The new Reader Revenue Manager Express Setup flow uses the webcontentpublisher API, which needs its own OAuth scopes rather than the subscribewithgoogle read-only scope the module requires today. Request https://www.googleapis.com/auth/webcontentpublisher.publications.readonly and https://www.googleapis.com/auth/webcontentpublisher.publications.manage when the user enters the express setup flow, and require the read-only scope for new setups, so that they grant it up front while existing users are not prompted.
For reference, see the Infrastructure section in the design doc.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The Reader Revenue Manager module requires
https://www.googleapis.com/auth/webcontentpublisher.publications.readonlyfor users setting up the module, and for users who have already granted it, so that new setups grant it up front and existing users holding onlysubscribewithgoogle.publications.readonlyare not prompted. - The module requires
https://www.googleapis.com/auth/webcontentpublisher.publications.managefor users who have already granted it - The express setup requests, on entry, any of the following scopes the user has not already granted:
https://www.googleapis.com/auth/webcontentpublisher.publications.readonlyhttps://www.googleapis.com/auth/webcontentpublisher.publications.manage- Any scopes required by the specific express setup flow.
- The scopes are requested when the user activates the flow from an entry point, and by the express setup screen when the flow is entered directly.
- When the user denies the OAuth consent screen, they are returned to the Site Kit dashboard with the standard OAuth error.
- When the user completes consent without granting a requested scope, the express setup does not request it again automatically, avoiding a loop.
- A request to an express setup write datapoint made without the manage scope returns a recognizable insufficient-scopes error, so that the publisher is prompted to grant it at the point of use.
- With
rrmExpressSetupoff, the module's required scopes and the standard Reader Revenue Manager setup are unchanged.
Implementation Brief
-
includes/Modules/Reader_Revenue_Manager.php- Add class constants for the two
webcontentpublisherscopes. - Under the
rrmExpressSetupflag, filtergooglesitekit_auth_scopesto refine the requested scopes per user, mirroringAnalytics_4::get_refined_scopes().get_scopes()itself is unchanged, so neither scope is required of the module unconditionally. - Add the
webcontentpublisherread-only scope when the user is not yet authenticated, when the module is not yet connected, or when they have already granted it, so that new setups grant it up front and existing users holding onlysubscribewithgoogle.publications.readonlyare not prompted. - Add the manage scope only when the user has already granted it, so that it is preserved across subsequent authorizations without the standard module setup asking for it.
- Declare the manage scope on the write datapoints, as
Analytics_4does for its edit scope, so that a call made without it throwsInsufficient_Scopes_Exception.googlesitekit/apidispatchessetPermissionScopeErrorfor that error code automatically, which prompts the publisher to grant it. Leave the read datapoints alone: the old read-only scope still authorizes the API during the migration period, and declaring the new one would reject calls that succeed.
- Add class constants for the two
-
assets/js/modules/reader-revenue-manager/datastore/constants.ts- Add
READONLY_SCOPEandMANAGE_SCOPEconstants for the two RRM OAuth scope strings.
- Add
-
assets/js/modules/reader-revenue-manager/components/setup/SetupMainExpress/constants.ts- Add
EXPRESS_SETUP_SCOPES, the scopes every express setup flow requires, so that the hook and the entry points share one list.
- Add
-
assets/js/hooks/useActivateModuleCallback.js- Optionally accept
additionalScopesas an array of strings inActivateModuleOptions.
- Optionally accept
-
assets/js/googlesitekit/modules/datastore/modules.js- Extend
activateModule( slug, options )action to destructureadditionalScopesfromoptionsand include them in theSELECT_MODULE_REAUTH_URLcontrol payload. - Update
SELECT_MODULE_REAUTH_URLcontrol to forwardadditionalScopesinto the module'sgetAdminReauthURLselector call.
- Extend
-
assets/js/googlesitekit/modules/create-info-store.js- Extend
getAdminReauthURLto acceptadditionalScopesalongside the existingreAuthoption. - Compute
unsatisfiedAdditionalScopesby filteringadditionalScopesthroughCORE_USER.hasScope. - Resolve to connect URL when
needsReauthenticationistrueorunsatisfiedAdditionalScopes.length > 0, passingunsatisfiedAdditionalScopesintoCORE_USER.getConnectURL.
- Extend
-
assets/js/modules/reader-revenue-manager/components/setup/SetupMainExpress/hooks.ts- Add a
useExpressSetupScopes( additionalScopes )hook that requestsEXPRESS_SETUP_SCOPESplus anything passed to it, so that each flow declares only what it adds. - Filter to scopes the user has not granted using
CORE_USER.hasScope, and request them in a singlesetPermissionScopeErrorcall withskipModal: trueandredirectURL: location.href, following the same immediate-OAuth-redirect pattern used inuseEnableAudienceGroup.js. This ensuresAuthenticatedPermissionsModalredirects to OAuth without presenting a confirmation dialog. - Do not pass
errorRedirectURL. Leaving it unset sends the user to the Site Kit dashboard with the standard OAuth error when they deny the consent screen. - Do not request a scope again when returning from a completed authorization without it, which
notification=authentication_successin the URL identifies. Deselecting a scope through Google's granular consent is not an OAuth error, so the publisher returns toredirectURLrather than to the dashboard, and re-requesting would loop.
- Add a
-
In
ExpressSetupDefault.tsxandcta-setups/SetupCTANewsletterSignup/index.tsx:- Call
useExpressSetupScopes(). Neither requires additional scopes.
- Call
-
Express setup entry point banner (Implement the RRM express setup dashboard entry point #12947) and RRM setup CTA banner (Update RRM setup CTA banner for express setup #12946)
- Wire the RRM express setup CTA activation call via
useActivateModuleCallbackwith:redirectQueryArgs: { expressSetup: true, cta: 'newsletter-signup' }additionalScopes: EXPRESS_SETUP_SCOPES
- A CTA that needs more than these defines them in its own
constants.ts, passed both here and touseExpressSetupScopes, so that a banner and its flow never request different sets.
- Wire the RRM express setup CTA activation call via
Test Coverage
- Update
create-info-storeselector tests. - Update
core/modulesactivation tests. - Update tests for the setup CTA and entry point banners as per the changes.
- Add tests for
useExpressSetupScopescovering the default scopes, additional scopes passed by a flow, a user who has already granted them, and a return from a completed authorization still missing a scope, asserting it is not requested again. - Add tests asserting the flows render the scope error in place of their steps when scopes are missing, and re-enter OAuth from its action.
- Add tests for the
googlesitekit_auth_scopesfilter covering an unauthenticated user, a connected user holding only the old read-only scope, a user who has granted the new read-only scope, a user who has granted the manage scope, and the flag off. - Add tests asserting the write datapoints throw
Insufficient_Scopes_Exceptionwithout the manage scope.
QA Brief
NOTE While we wait for re-approval of the OAuth app for the new scopes, a "This app is blocked" error will appear when authenticating, with no way to proceed. Until the approval is granted this issue can be tested by using the staging proxy.
Between each of the following tests, go to https://myaccount.google.com/ > Linked apps > Site Kit and Delete all.
RRM setup without Express Setup enabled
- Set up Site Kit without
rrmExpressSetupenabled. - Set up Reader Revenue Manager from Settings > Connect more services.
- You will be redirected to authenticate and prompted to grant access to See and review your publication data (there won't be a checkbox because it's a single permission).
- Setup should proceed as normal.
RRM setup with Express Setup enabled
- Set up Site Kit with
rrmExpressSetupenabled. - Set up Reader Revenue Manager from Settings > Connect more services.
- You will need to authenticate and you should be prompted to grant access to:
- See information on newsletter sign-up forms.
- See and review your publication data.
- Grant them and setup should proceed as normal.
RRM setup with Express Setup enabled, without granting permissions
- Set up Site Kit with
rrmExpressSetupenabled. - Set up Reader Revenue Manager from Settings > Connect more services.
- You will need to authenticate and you should be prompted to grant access to:
- See information on newsletter sign-up forms.
- See and review your publication data.
- Clicking Cancel, or Continue without granting both permissions should redirect to the dashboard where a Site Kit can’t access necessary data notice will be shown.
- Clicking Redo setup should return to the authentication step. Granting both permissions should return you to the Reader Revenue Manager setup where you'll be prompted to select a publication.
RRM setup initiated with Express Setup
- Set up Site Kit with
rrmExpressSetupenabled. - From the dashboard, in the Collect reader emails directly on your site widget, click Set up a sign-up form.
- You will need to authenticate and you should be prompted to grant access to:
- Read and edit information on newsletter sign-up forms.
- See information on newsletter sign-up forms.
- See and review your publication data.
- Granting all permissions should return to Express Setup, which should proceed as normal.
RRM setup initiated with Express Setup, without granting permissions
- Set up Site Kit with
rrmExpressSetupenabled. - From the dashboard, in the Collect reader emails directly on your site widget, click Set up a sign-up form.
- You will need to authenticate and you should be prompted to grant access to:
- Read and edit information on newsletter sign-up forms.
- See information on newsletter sign-up forms.
- See and review your publication data.
- Clicking Cancel, or Continue without granting all permissions should redirect to the dashboard where a Site Kit can’t access necessary data notice will be shown.
- Clicking Redo setup should return to the authentication step where you should be prompted for the same 3 permissions. Granting all of them should return to Express Setup, which should proceed as normal.
Express Setup after RRM setup
- Set up Site Kit with
rrmExpressSetupenabled. - Set up Reader Revenue Manager from Settings > Connect more services.
- You will need to authenticate and you should be prompted to grant access to:
- See information on newsletter sign-up forms.
- See and review your publication data.
- Grant them and setup should proceed as normal.
- Navigate directly to
/wp-admin/admin.php?page=googlesitekit-dashboard&slug=reader-revenue-manager&reAuth=true&expressSetup=true&cta=newsletter-signup. - You will be redirected to authenticate and prompted to grant access to Read and edit information on newsletter sign-up forms (there won't be a checkbox because it's a single permission).
- Clicking continue should return to Express Setup, which should proceed as normal.
Express Setup after RRM setup, without granting permissions
- Set up Site Kit with
rrmExpressSetupenabled. - Set up Reader Revenue Manager from Settings > Connect more services.
- You will need to authenticate and you should be prompted to grant access to:
- See information on newsletter sign-up forms.
- See and review your publication data.
- Grant them and setup should proceed as normal.
- Navigate directly to
/wp-admin/admin.php?page=googlesitekit-dashboard&slug=reader-revenue-manager&reAuth=true&expressSetup=true&cta=newsletter-signup. - You will be redirected to authenticate and prompted to grant access to Read and edit information on newsletter sign-up forms (there won't be a checkbox because it's a single permission).
- Clicking Cancel should redirect to the dashboard where a Site Kit can’t access necessary data notice will be shown.
- Clicking Redo setup should return to the authentication step where you should be prompted for the same Read and edit information on newsletter sign-up forms permission. Granting all of them should return to Express Setup, which should proceed as normal.
Repeat each test without removing Site Kit from Linked apps. At each step where you were previously prompted to grant specific permissions you should instead be shown an "X already has some access" message with "See the Y services that X has some access to." Clicking Y services should show a list of permissions that includes the permissions that you were prompted to grant when they had not already been granted.
Changelog entry
- N/A.
Activity
nfmohit commentedon Jul 4, 2026
AC ✅
nfmohit commentedon Jul 7, 2026
Hi @ankitrox. Thank you for drafting the IB.
I'm afraid, this is not going to satisfy the ACs, because this would mean that the existing standard RRM module setup will also require this scope, which we do not want. We only want to ask for this scope when the user uses the express setup.
This will need a mostly client-side approach, with the
useActivateModuleCallbackhook,activateModuleaction,SELECT_MODULE_REAUTH_URLcontrol, andgetAdminReauthURLselector extended to optionally support:?expressSetup=true&cta=newsletter-signupafter module activation.getConnectURLalready supports it.I have created a small PoC (#13070) to demonstrate my thoughts behind this. I'll also loop in @aaemnnosttv to review if this approach looks good.
Thanks!
30 remaining items
JakePT commentedon Sep 24, 2026
Regarding the QAB steps I have noted as failing, the IB adds
additionalScopesto module activation but overlooks preserving it andredirectQueryArgsacross failed authorization attempts.useActivateModuleCallbackcaches only the module slug, andUnsatisfiedScopesAlertretries activation without the original options. Consequently, “Redo setup” omits the manage scope and loses the express setup return destination. As per a Slack conversation with @nfmohit this will be addressed in a follow-up rather than blocking this issue.nfmohit commentedon Sep 27, 2026
@JakePT Both PRs for this issue have been merged. I'm assigning this issue to you in QA to make any necessary updates to the QAB, including instructions for using the staging proxy. We're currently having issues requesting these new scopes in production, and we are working on resolving them. Thanks!
kelvinballoo commentedon Sep 30, 2026
QA Update⚠️
This is mostly tested good.
I just have a clarification on the last test case, more specifically to this step:
**Clicking Redo setup should return to the authentication step where you should be prompted for the same 3 permissions.** Granting all of them should return to Express Setup, which should proceed as normal.So, when I click 'Redo', I am not prompted for 3 permissions but for only 1 (Read and edit information on newsletter sign-up forms)
I assume that's fine but since it deviates from the QAB, I am flagging for confirmation first.
Details
I have attached the full video also for reference.
Details
13004.-.07.Express.Setup.after.RRM.setup.without.granting.permissions.maybe.ok.mov
JakePT commentedon Sep 30, 2026
@kelvinballoo Ah yep, that's fine. That's a mistake in the QAB where I copied the step text from the earlier case and didn't update the count. I've updated the QAB.
The important thing is that clicking Redo should always ask for the same permissions that it was asking for when previously cancelling. In the earlier case it should be all 3, but in the Express Setup after RRM setup, without granting permissions case it should just be that one additional permission it asked for. Thanks for checking!
kelvinballoo commentedon Sep 30, 2026
QA Update ✅
Thanks @JakePT . With that in mind, it's good to move to approval.
All the test cases were verified good with the removal of the Linked permissions and without.
RRM setup without Express Setup enabled
Details
13004.-.01.RRM.setup.without.xpress.flag.ok.mov
13004.-.01.RRM.setup.without.xpress.flag.ok.w.o.linked.step.mov
RRM setup with Express Setup enabled
Details
13004.-.02.RRM.setup.with.Express.Setup.enabled.mov
13004.-.02.RRM.setup.with.Express.Setup.enabled.w.o.linked.step.mov
RRM setup with Express Setup enabled, without granting permissions
Details
13004.-.03.RRM.setup.with.Express.Setup.enabled.without.granting.permissions.mov
13004.-.03.RRM.setup.with.Express.Setup.enabled.without.granting.permissions.w.o.linked.step.mov
RRM setup initiated with Express Setup
Details
13004.-.04.RRM.setup.initiated.with.Express.Setup.mov
13004.-.04.RRM.setup.initiated.with.Express.Setup.w.o.linked.step.mov
RRM setup initiated with Express Setup, without granting permissions
Details
13004.-.05.RRM.setup.initiated.with.Express.Setup.without.granting.permissions.mov
13004.-.05.RRM.setup.initiated.with.Express.Setup.without.granting.permissions.w.o.linked.step.mov
Express Setup after RRM setup
Details
13004.-.06.Express.Setup.after.RRM.setup.mov
13004.-.06.Express.Setup.after.RRM.setup.w.o.linked.step.mov
Express Setup after RRM setup, without granting permissions
Details
13004.-.07.Express.Setup.after.RRM.setup.without.granting.permissions.maybe.ok.mov
13004.-.07.Express.Setup.after.RRM.setup.without.granting.permissions.without.linked.step.mov