Skip to content

Commit

Permalink
Adds multiple account functionality. Closes #3587
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlingstuyl committed Oct 22, 2023
1 parent d53f0d9 commit 9914a06
Show file tree
Hide file tree
Showing 27 changed files with 2,053 additions and 317 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dictionary = [
'historical',
'home',
'hub',
'identity',
'in',
'info',
'inheritance',
Expand Down
105 changes: 105 additions & 0 deletions docs/docs/cmd/identity/identity-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import Global from '/docs/cmd/_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# identity list

Shows a list of currently signed in identities

## Usage

```sh
m365 identity list [options]
```

## Options

<Global />

## Remarks

If you are logged in to Microsoft 365, the `identity list` command will show you a list of users and/or applications used to sign in and the details about the stored refresh and access tokens and their expiration date and time when run in debug mode.

## Examples

Show the list of available identities used to sign in to Microsoft 365

```sh
m365 identity list
```

## Response

<Tabs>
<TabItem value="JSON">

```json
[
{
"connectedAs": "alexw@contoso.com",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
"cloudType": "Public"
},
{
"connectedAs": "Contoso Application",
"identityId": "acd6df42-10a9-4315-8928-53334f1c9d01",
"authType": "Secret",
"appId": "39446e2e-5081-4887-980c-f285919fccca",
"appTenant": "db308122-52f3-4241-af92-1734aa6e2e50",
"cloudType": "Public"
}
]
```

</TabItem>
<TabItem value="Text">

```text
connectedAs authType
------------------------------------ -----------------------------------------------
alexw@contoso.com DeviceCode
Contoso Application Secret
```

</TabItem>
<TabItem value="CSV">

```csv
connectedAs,identityId,authType,appId,appTenant,cloudType
alexw@contoso.com,028de82d-7fd9-476e-a9fd-be9714280ff3,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public
Contoso Application,acd6df42-10a9-4315-8928-53334f1c9d01,Secret,39446e2e-5081-4887-980c-f285919fccca,db308122-52f3-4241-af92-1734aa6e2e50,Public
```

</TabItem>
<TabItem value="Markdown">

```md
# identity list

Date: 7/2/2023

Property | Value
---------|-------
connectedAs | alexw@contoso.com
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
cloudType | Public

Property | Value
---------|-------
connectedAs | Contoso Application
identityId | acd6df42-10a9-4315-8928-53334f1c9d01
authType | Secret
appId | 39446e2e-5081-4887-980c-f285919fccca
appTenant | db308122-52f3-4241-af92-1734aa6e2e50
cloudType | Public
```

</TabItem>
</Tabs>

107 changes: 107 additions & 0 deletions docs/docs/cmd/identity/identity-set.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import Global from '/docs/cmd/_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# identity set

Switches to another identity, when signed into multiple identities

## Usage

```sh
m365 identity set [options]
```

## Options

```md definition-list
`-i, --id [id]`
: The Id (GUID) of the identity to switch to. Specify either `id` or `name` but not both.

`-n, --name [name]`
: The name of the identity to switch to. Specify either `id` or `name` but not both.
```

<Global />

## Remarks

The values for `--id` or `--name` can be found by running [m365 identity list](identity-list.mdx).

## Examples

Switch to a user identity by name

```sh
m365 identity set --name 'alexw@contoso.com'
```

Switch to a given identity by id

```sh
m365 identity set --id '6e70c8ea-571d-4daf-bc48-9e1b49ac3390'
```

Switch to an application identity by name

```sh
m365 identity set --name 'My contoso application'
```

## Response

<Tabs>
<TabItem value="JSON">

```json
{
"connectedAs": "alexw@contoso.com",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
"cloudType": "Public"
}
```

</TabItem>
<TabItem value="Text">

```text
appId : 31359c7f-bd7e-475c-86db-fdb8c937548e
identityId : 028de82d-7fd9-476e-a9fd-be9714280ff3
appTenant : common
authType : DeviceCode
connectedAs: alexw@contoso.com
cloudType : Public
```

</TabItem>
<TabItem value="CSV">

```csv
connectedAs,authType,appId,appTenant,cloudType
alexw@contoso.com,028de82d-7fd9-476e-a9fd-be9714280ff3,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public
```

</TabItem>
<TabItem value="Markdown">

```md
# identity set

Date: 7/2/2023

Property | Value
---------|-------
connectedAs | alexw@contoso.com
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
cloudType | Public
```

</TabItem>
</Tabs>

13 changes: 7 additions & 6 deletions docs/docs/cmd/login.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ m365 login --authType secret --secret topSeCr3t@007
Upon successful login:
```json
{
"connectedAs": "john.doe@contoso.onmicrosoft.com",
"connectedAs": "alexw@contoso.com",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
Expand All @@ -203,9 +204,10 @@ m365 login --authType secret --secret topSeCr3t@007
Upon successful login:
```text
appId : 31359c7f-bd7e-475c-86db-fdb8c937548e
identityId : 028de82d-7fd9-476e-a9fd-be9714280ff3
appTenant : common
authType : DeviceCode
connectedAs: john.doe@contoso.onmicrosoft.com,
connectedAs: alexw@contoso.com
cloudType : Public
```

Expand All @@ -218,7 +220,7 @@ m365 login --authType secret --secret topSeCr3t@007
Upon successful login:
```csv
connectedAs,authType,appId,appTenant,cloudType
john.doe@contoso.onmicrosoft.com,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public
alexw@contoso.com,028de82d-7fd9-476e-a9fd-be9714280ff3,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public
```

</TabItem>
Expand All @@ -233,11 +235,10 @@ m365 login --authType secret --secret topSeCr3t@007

Date: 7/2/2023



Property | Value
---------|-------
connectedAs | john.doe@contoso.onmicrosoft.com
connectedAs | alexw@contoso.com
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
Expand Down
28 changes: 25 additions & 3 deletions docs/docs/cmd/logout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ m365 logout [options]

## Options

```md definition-list
`-i, --identityId [identityId]`
: The optional Id (GUID) of the identity to logout from. Specify either `identityId` or `identityName` but not both. If not specified, all identities will be logged out from.

`-n, --identityName [identityName]`
: The optional name of the identity to switch to. Specify either `identityId` or `identityName` but not both. If not specified, all identities will be logged out from.
```

<Global />

## Remarks

The `logout` command logs out from Microsoft 365 and removes any access and refresh tokens from memory
The `logout` command logs out from Microsoft 365 and removes any access and refresh tokens from memory.

The values for `--identityId` or `--identityName` can be found by running [m365 identity list](identity/identity-list.mdx).

## Examples

Expand All @@ -26,10 +36,22 @@ Log out from Microsoft 365
m365 logout
```

Log out from Microsoft 365 in debug mode including detailed debug information in the console output
Log out from a given user identity by name

```sh
m365 logout --identityName 'alexw@contoso.com'
```

Log out from a given application identity by name

```sh
m365 logout --identityName 'My contoso application'
```

Log out from a given identity by id

```sh
m365 logout --debug
m365 logout --identityId '23269cc7-c005-4a36-b020-b6e99f997710'
```

## Response
Expand Down
13 changes: 7 additions & 6 deletions docs/docs/cmd/status.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ m365 status

```json
{
"connectedAs": "john.doe@contoso.onmicrosoft.com",
"connectedAs": "alexw@contoso.com",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
Expand All @@ -48,9 +49,10 @@ m365 status

```text
appId : 31359c7f-bd7e-475c-86db-fdb8c937548e
identityId : 028de82d-7fd9-476e-a9fd-be9714280ff3
appTenant : common
authType : DeviceCode
connectedAs: john.doe@contoso.onmicrosoft.com
connectedAs: alexw@contoso.com
cloudType : Public
```

Expand All @@ -59,7 +61,7 @@ m365 status

```csv
connectedAs,authType,appId,appTenant,cloudType
john.doe@contoso.onmicrosoft.com,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public
alexw@contoso.com,028de82d-7fd9-476e-a9fd-be9714280ff3,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public
```

</TabItem>
Expand All @@ -70,11 +72,10 @@ m365 status

Date: 7/2/2023



Property | Value
---------|-------
connectedAs | john.doe@contoso.onmicrosoft.com
connectedAs | alexw@contoso.com
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
Expand Down
14 changes: 14 additions & 0 deletions docs/src/config/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,20 @@ const sidebars = {
}
]
},
{
'Identity (identity)': [
{
type: 'doc',
label: 'list',
id: 'cmd/identity/identity-list'
},
{
type: 'doc',
label: 'set',
id: 'cmd/identity/identity-set'
}
]
},
{
'Microsoft 365 apps (app)': [
{
Expand Down
Loading

0 comments on commit 9914a06

Please sign in to comment.