fix(oauth): keep the oauth context after a page refresh

This fixes #1251.

When you start an OAuth flow the original browser tab will have a `client_id` query parameter instead of the `service` parameter, which the current code expects. This PR will use the `client_id` when available if the service hasn't been set.

@vladikoff r?
These functions were added as methods so that we can use the instance's `window` reference during testing.