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 26, 2023
1 parent d53f0d9 commit 2e34ede
Show file tree
Hide file tree
Showing 28 changed files with 2,072 additions and 321 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
[
{
"identityName": "[email protected]",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
"cloudType": "Public"
},
{
"identityName": "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
identityName authType
------------------------------------ -----------------------------------------------
[email protected] DeviceCode
Contoso Application Secret
```

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

```csv
identityName,identityId,authType,appId,appTenant,cloudType
[email protected],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
---------|-------
identityName | [email protected]
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
cloudType | Public

Property | Value
---------|-------
identityName | 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 '[email protected]'
```

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
{
"identityName": "[email protected]",
"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
appTenant : common
authType : DeviceCode
cloudType : Public
identityId : 028de82d-7fd9-476e-a9fd-be9714280ff3
identityName: [email protected]
```

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

```csv
identityName,identityId,authType,appId,appTenant,cloudType
[email protected],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
---------|-------
identityName | [email protected]
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
cloudType | Public
```

</TabItem>
</Tabs>

20 changes: 12 additions & 8 deletions docs/docs/cmd/login.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ m365 login --authType secret --secret topSeCr3t@007
Upon successful login:
```json
{
"connectedAs": "[email protected]",
"identityName": "[email protected]",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
"cloudType": "Public"
"cloudType": "Public",
"connectedAs": "[email protected]"
}
```

Expand All @@ -205,8 +207,10 @@ m365 login --authType secret --secret topSeCr3t@007
appId : 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant : common
authType : DeviceCode
connectedAs: [email protected],
cloudType : Public
connectedAs: [email protected]
identityId : 028de82d-7fd9-476e-a9fd-be9714280ff3
identityName: [email protected]
```

</TabItem>
Expand All @@ -217,8 +221,8 @@ 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
identityName,identityId,authType,appId,appTenant,cloudType,connectedAs
alexw@contoso.com,028de82d-7fd9-476e-a9fd-be9714280ff3,DeviceCode,31359c7f-bd7e-475c-86db-fdb8c937548e,common,Public,[email protected]
```

</TabItem>
Expand All @@ -233,15 +237,15 @@ m365 login --authType secret --secret topSeCr3t@007

Date: 7/2/2023



Property | Value
---------|-------
connectedAs | [email protected]
identityName | [email protected]
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
cloudType | Public
connectedAs | [email protected]
```

</TabItem>
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 '[email protected]'
```

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
20 changes: 12 additions & 8 deletions docs/docs/cmd/status.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ m365 status

```json
{
"connectedAs": "[email protected]",
"identityName": "[email protected]",
"identityId": "028de82d-7fd9-476e-a9fd-be9714280ff3",
"authType": "DeviceCode",
"appId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"appTenant": "common",
"cloudType": "Public"
"cloudType": "Public",
"connectedAs": "[email protected]"
}
```

Expand All @@ -50,16 +52,18 @@ m365 status
appId : 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant : common
authType : DeviceCode
connectedAs: [email protected]
cloudType : Public
connectedAs: [email protected]
identityId : 028de82d-7fd9-476e-a9fd-be9714280ff3
identityName: [email protected]
```

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

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

</TabItem>
Expand All @@ -70,15 +74,15 @@ m365 status

Date: 7/2/2023



Property | Value
---------|-------
connectedAs | [email protected]
identityName | [email protected]
identityId | 028de82d-7fd9-476e-a9fd-be9714280ff3
authType | DeviceCode
appId | 31359c7f-bd7e-475c-86db-fdb8c937548e
appTenant | common
cloudType | Public
connectedAs | [email protected]
```

</TabItem>
Expand Down
Loading

0 comments on commit 2e34ede

Please sign in to comment.