Skip to content

Conversation

@lopezvoliver
Copy link
Member

This pull request adds the ability to sign in users directly through the extension using a loopback oauth flow, saving the refresh token as a secret, as well as the ability to sign out (removing the account information from the extension). To accommodate for this option, some internal changes were necessary.

Here are some screenshots of the process:

signin-allow

Left: vscode window displaying an information message with progress bar and Cancel button. Right: Browser opened to accounts.google.com with Cancel and Allow buttons.

signin-close

Left: vscode window displaying a message after successful sign in. Right: Browser redirected to the local server with a message after successful sign in.

If the user cancels the sign in, an error message is displayed:

signin-cancel

Left: vscode window displaying an error message. Right: Browser redirected to the local server with the error message.

Here's a preview of the new look for the account picker:

eetasks-users

Here's an overview of the changes:

  1. The account provided to the EETasksPanel.render and scriptRunnerAsAccount is now of type IPickedAccount {name:string, kind:string} instead of simply string. This is because the getToken module, specifically the newToken function now relies on kind to determine how to retrieve a new token. This change is propagated in all necessary functions within those modules.
  2. Short-lived tokens stored in the extension state were previously saved to userAccounts as {account:token} (key:value) pairs. The structure of userAccounts is now IAccounts{[name:string]:IAccount}, where IAccount{kind:string, token: string | null}. Again, this is to accommodate the differences between gcloud accounts, the persistent credentials from the python earthengine-api, and the new signed-in accounts.
  3. Signed-in accounts take priority over accounts of the same name from gcloud. When updating accounts through the Update available accounts command, if an account already exists with kind Signed in, it is not added as another account. When a new account is signed in, the account is saved with kind Signed in, replacing any existing account of the same name.
  4. The items in the accounts quick pick are now categorized by kind (see below). If there are more than one kind of available accounts, quickpick items of kind vscode.QuickPickItemKind.Separator are added so that they get displayed in the list.
    • Signed-in
    • python earthengine-api credentials
    • gcloud
  5. The labels in the accounts quick pick items now also contain a codicon to represent the account kind. This is not just for aesthetics, but to encode the kind information within the label in the quickpick item itself so that it can be retrieved once the account is picked (and finally pass the IPickedAccount object to the callback function).
    • codicon-account $(account) for Signed-in accounts.
    • codicon-snake $(snake) for python earthengine-api credentials
    • codicon-terminal-view-icon $(terminal-view-icon) for gcloud accounts.
  6. Breaking change: the defaultAccount and defaultProject is now removed from the extension configuration. Instead, a new Pick default account command lets the user pick the account and project to set as the default, which are stored in the extension context.
  7. A new Sign out command was added, which lets the user pick the account to sign-out from, deleting the account from userAccounts, as well as the secret refreshToken for that account.

@lopezvoliver lopezvoliver merged commit 26da2ae into gee-community:main Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant