site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Add explanation how to re-activate modules in Settings page

Open bjackson27 opened this issue 7 years ago • 10 comments

If a user doesn't approve all scopes, we show an error "not all scopes approved", but no information how to fix that. Add language to tell the user they need to disconnect the service and begin setup from scratch.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

For cases where the user hasn't approved all requested scopes during the setup, display the following error message:

  • Heading: Site Kit can't access necessary data
  • Text: Site Kit can't access the relevant data from $PRODUCT because you haven't granted all API scopes requested during setup. To use Site Kit, you'll need to redo the setup for $PRODUCT – make sure to approve all API scopes at the authentication stage.
  • Button: Redo setup

The text above should include variants for the following cases:

  • Scopes from multiple services/products are missing
  • We're not able to determine which service/product is responsible for the missing required scope(s)

This is the same message displayed in #1114.

Implementation Brief

In the DashboardAuthAlert component:

  • Change the title prop to Site Kit can't access necessary data
  • Identify product/services missing scopes by parsing the list of unsatisfied scopes from global.googlesitekit.setup.unsatisfiedScopes
  • Parse product/service IDs from each scope in the list https://www.googleapis.com/auth/{productOrServiceID}.potential.other.segments
    • Note: the productOrServiceID above generally maps to a module slug, but there are exceptions (e.g. webmasters -> search-console) which need to be accounted for
    • .potential.other.segments may or may not be present, where it is a dot-separated string irrelevant to the matching of productOrServiceID
  • Set the description prop to Site Kit can't access the relevant data from $PRODUCT because you haven't granted all API scopes requested during setup. To use Site Kit, you'll need to redo the setup for $PRODUCT – make sure to approve all API scopes at the authentication stage. using sprintf to pass the product name.
    • Include a variant that lists the names of multiple products
    • Include a generic variant for handling the rare case where no product or service is inferrable
    • Exact verbaige TBD
  • change the ctaLabel prop to Redo setup

Changelog entry

  • Clarify message for when user needs to reauthenticate to grant required scopes.

bjackson27 avatar Jul 10 '19 21:07 bjackson27

@bjackson27 presumably this would show up not just in the Settings, but also during the setup process. Do we have screenshots of how this would look during setup? That would help define the acceptance criteria.

marrrmarrr avatar Jul 22 '19 10:07 marrrmarrr

IB ✅

felixarntz avatar May 06 '20 22:05 felixarntz

Tested

Installed latest SK, activated and went through Adsense proxy, canceled after selecting my member. Notice series of strange copy

Site Kit can't access the relevant data from Splash because...

Site Kit can't access the relevant data from Dashboard because...

Site Kit by Google Dashboard ‹ Hellogoodbye — WordPress (3)

image

Sending this back for revision @ShahAaron

cole10up avatar May 22 '20 07:05 cole10up

@felixarntz I suggested that we derive the service/product name from the missing scope(s) which I still think is better than inferring from the screen, but there's a still few problems with this approach to be addressed:

  • The user could have multiple scopes from different services that weren't granted. In this case it would be inaccurate and potentially counter-productive to only name one of them in the notification as the user might only allow the permissions for that service and not for the other.
  • This doesn't take implicit scope satisfaction into consideration when the user has a higher scope already granted where the scope implicitly grants the lower .readonly scope. We've accounted for this on the server-side with the Scopes utility class. Rather than porting this same class to JS, for now I think the simpler solution would be to extend googlesitekit.setup and core/user/data/authentication with a new unsatisfiedScopes key. We need to also make sure we're not using the simple count or array comparison logic for "needsAuth" logic anywhere as this will no longer be accurate.
  • In the case that no product name is matched, we should use an alternate more generic version of the message.

aaemnnosttv avatar May 27 '20 08:05 aaemnnosttv

@aaemnnosttv Good catch, I like the approach of including an array of unsatisfiedScopes to the data. Basically this would make needsReauthentication unnecessary, but let's keep it nonetheless as it's just a simple boolean to check.

felixarntz avatar May 27 '20 16:05 felixarntz

@felixarntz I just updated the AC/IB to include the things we talked about. Let me know if there's anything there I missed.

aaemnnosttv avatar May 27 '20 18:05 aaemnnosttv

@aaemnnosttv LGTM!

@ryanwelcher The PR #1586 has been updated with the latest develop. It now includes a OAuth_Client::get_unsatisfied_scopes() method, which you can use here to populate unsatisfiedScopes (in googlesitekit.setup object and core/user/data/authentication API datapoint, see above). It returns the array of scopes that are required but not granted. Essentially it's a more "precise" variant of needsReauthentication (if the array is not empty, needsReauthentication will be true).

felixarntz avatar May 27 '20 23:05 felixarntz

@felixarntz I created a PR with the necessary changes for unsatisfiedScopes which @ryanwelcher should be able to use here until #1599 is merged.

aaemnnosttv avatar May 28 '20 15:05 aaemnnosttv

@ryanwelcher @aaemnnosttv #1599 is merged so this should be good to be picked up again!

felixarntz avatar May 28 '20 16:05 felixarntz

Retested - Looks good on my end.

Passed QA ✅

cole10up avatar Jun 01 '20 15:06 cole10up