Comment 5 for bug 1724316

Revision history for this message
James Henstridge (jamesh) wrote :

So further investigation, the "cannot authenticate to snap store: " part of the error is only added by snapd for an unexpected error:

    https://github.com/snapcore/snapd/blob/master/store/auth.go#L190-L204

I believe this is being called via the refreshDischarges() method, intended to keep the store macaroon up to date. This is called by any snapd API that talks to the store, so it isn't surprising we'd hit it during gnome-software start up.

I wonder if changing your Ubuntu One password would be enough for the store to refuse to refresh the macaroon?

So it looks like the fix probably requires the following:

 1. snapd to handle the INVALID_CREDENTIALS response from the store and produce an error response that snapd-glib can distinguish.

 2. snapd-glib to handle this error case and map it to one of its error codes (either a new one, or fold it into invalid-auth-data?)

 3. if snapd-glib produces a new error code, for gnome-software's snap plugin to map this to an appropriate error code.

The end result should be for gnome-software to call the /v2/login end point again, probably passing its existing macaroon so it updates the existing snapd user rather than creating another (i.e. what would happen to paid snaps for a discarded snapd user ID when it comes time to refresh?). I'll follow up with the snappy team to verify that this is the way forward.