Cli-microsoft365: Rename the '[service] connect' commands to '[service] login'

Created on 7 Sep 2018  路  4Comments  路  Source: pnp/cli-microsoft365

We should rename all connect commands (like spo connect, graph connect, etc.) to login (spo login, graph login), to clearer indicate that the command is meant to obtain an access token rather than establish a working context.

The currently used connect name is particularly confusing when working with SharePoint commands. If you've worked with CSOM or PnP PowerShell, you know that before performing an operation on a site you have to connect to that particular site. Everything you do afterwards, will assume the context of the site to which you connected.
This isn't the case with the CLI, where you can connect once and operate on any site in your tenant you want. Connecting to a service means obtaining an access token. Because you don't need a different access token for each site, there is no need to reconnect. In each command that operates on site-scoped resources, you specify the URL of the site through its arguments.

@andrewconnell and I realized this when discussing some commands in the CLI and how they operate on the different resources. We came to the conclusion that changing the name from connect to login would make it clearer that you only need to sign in once and unless you want to communicate with a different tenant, you can work with any site without reconnecting.

To prevent a breaking change, we wouldn't remove the connect command but would show a deprecation warning suggesting using the login command instead. The internal working of the command would remain as-is. For consistency, we'd also introduce a logout command which would be a counterpart to disconnect.

What do you think? @VelinGeorgiev @rfjschouten @RARomano @mpowney @wictorwilen

enhancement question work in progress

Most helpful comment

Piling on... why login & logout? It matches what the Azure CLI uses.

All 4 comments

Piling on... why login & logout? It matches what the Azure CLI uses.

If you're interested how it would look like, check out #578

I agree that this is much clearer. Just a small remark; shouldn't lines like the following also be updated to match the change from connect to login?

     cmd.log({
       connectedTo: auth.site.url,
       connectedAs: Utils.getUserNameFromAccessToken(auth.service.accessToken)
     });

So maybe use something like 'Logged in to' and 'Logged in as'?

Lines like these can be found in the following files

  • office365-cli/src/o365/aad/commands/status.ts
  • office365-cli/src/o365/azmgmt/commands/status.ts
  • office365-cli/src/o365/graph/commands/status.ts
  • office365-cli/src/o365/spo/commands/status.ts

Theoretically yes, but if you look closely, this is command output which someone might have taken dependency on in a script they've built. If we changed it, it would mean a breaking change. So for now, I'd be ok with keeping the old naming in status commands.

Was this page helpful?
0 / 5 - 0 ratings