Skip to content

Commit f9a1d52

Browse files
garrytrinderwaldekmastykarz
authored andcommitted
Update sample readme and scripts
1 parent a17d340 commit f9a1d52

File tree

3 files changed

+39
-47
lines changed

3 files changed

+39
-47
lines changed

samples/readme.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
- [Pre-requisites](#prereqs)
66
- [Configure Azure AD App Registration](#appreg)
7-
- [Script](#script)
7+
- [PowerShell 7](#pwsh)
8+
- [Bash](#bash)
89
- [Manual](#manual)
910
- [Launch Sample](#launch)
1011

@@ -18,35 +19,41 @@ We highly recommend that you use a Microsoft 365 Developer Tenant with content p
1819

1920
## <a id="appreg">Configure Azure AD App Registration</a>
2021

21-
There are two ways which you can configure the App Registration required for the samples to work correctly, through automatation using a bash script or manually through Azure Portal.
22+
There are two ways which you can configure the App Registration required for the samples to work correctly, through automatation using either a `bash` or `pwsh` script we provide for you in the `scripts` directory, or manually through Azure Portal.
2223

23-
### <a id="script">Script</a>
24+
### <a id="pwsh">PowerShell 7</a>
2425

25-
If using PowerShell:
26-
```powershell
27-
.\scripts\setup.ps1
26+
> The script uses CLI for Microsoft 365 to authenticate with and create the app registration in your tenant, therefore requires nodejs, v8 or greater to be installed
27+
28+
```sh
29+
PS > cd ./samples/
30+
PS > ./scripts/setup.ps1
2831
```
2932

30-
If using a Linux/Mac terminal:
31-
```shell
33+
Follow the prompts in the terminal.
34+
35+
### <a id="bash">bash</a>
36+
37+
> The script uses CLI for Microsoft 365 to authenticate with and create the app registration in your tenant, therefore requires nodejs, v8 or greater to be installed
38+
39+
```sh
40+
$ > cd ./samples/
3241
$ > chmod +x /scripts/setup.sh
3342
$ > ./scripts/setup.sh
3443
```
3544

3645
Follow the prompts in the terminal.
3746

38-
> The script uses CLI for Microsoft 365 to authenticate with and create the app registration in your tenant, therefore requires nodejs, v8 or greater to be installed
39-
40-
## <a id="manual">Manual</a>
47+
### <a id="manual">Manual</a>
4148

4249
The following table provides details of how to configure your app registration.
4350

4451
| Property | Value |
4552
| ---- | ---- |
4653
| Name | Microsoft Graph Chaos Proxy Samples |
4754
| Platform type | Single-page application |
48-
| Redirect URIs | http://localhost:5500/withsdk.html <br> http://localhost:5500/nosdk.html |
49-
| API Permissions | Microsoft Graph <br> User.Read.All (Delegate) <br> Presence.Read.All |
55+
| Redirect URIs | http://localhost:3000/withsdk.html <br> http://localhost:3000/nosdk.html |
56+
| API Permissions | Microsoft Graph <br> User.Read.All (Delegate) w/ Admin Consent <br> Presence.Read.All |
5057

5158
After creating the app registation, create a file called `env.js` in the root of the `samples` directory with the following contents, replacing `<clientid>` with the value which can be copied from the portal.
5259

@@ -56,18 +63,9 @@ const appId = '<clientid>';
5663

5764
## <a id="launch">Launch Sample</a>
5865

59-
Follow these instructions to launch the samples using the Visual Studio Code [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) extension.
60-
61-
> !!! IMPORTANT !!!
62-
> The default host name used by Live Server is `127.0.0.1`, therefore you will need to change the `liveServer.settings.host` setting to `localhost` for the samples to work correctly, as `127.0.0.1` is not a valid Redirect URI.
63-
64-
Open the `samples` directory in Visual Studio Code
65-
66-
```shell
67-
$ > cd samples
68-
$ > code .
66+
```sh
67+
$ > cd ./samples/
68+
$ > npx lite-server
6969
```
7070

71-
Start `Live Server`
72-
7371
![Samples](img/samples.png)

samples/scripts/setup.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ npx -p @pnp/cli-microsoft365 -- m365 login --authType browser
44

55
# create AAD app
66
Write-Output "Creating AAD app..."
7-
$appId = npx -p @pnp/cli-microsoft365 -- "m365 aad app add --name Graph-Chaos-Proxy-Samples --multitenant --redirectUris http://localhost:5500/withsdk.html,http://localhost:5500/nosdk.html --apisDelegated https://graph.microsoft.com/User.Read.All,https://graph.microsoft.com/Presence.Read.All --platform spa --query appId -o text"
7+
$appId = npx -p @pnp/cli-microsoft365 -- "m365 aad app add --name graph-chaos-proxy-samples --multitenant --redirectUris http://localhost:3000/withsdk.html,http://localhost:3000/nosdk.html --apisDelegated https://graph.microsoft.com/User.Read.All,https://graph.microsoft.com/Presence.Read.All --grantAdminConsent --platform spa --query appId -o text"
88

99
Write-Output "AppId: $appId"
1010

1111
# write app to env.js
1212
Write-Output "Writing app to env.js..."
1313
"const appId = '$appId';" | Out-File .\env.js
1414

15-
# write app to env_esm.js
16-
"export const appId = '$appId';" | Out-File .\env_esm.js
17-
1815
Write-Output "DONE"

samples/scripts/setup.sh

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
#!/usr/bin/env bash
2-
3-
# login
4-
echo "Sign in to Microsoft 365..."
5-
npx -p @pnp/cli-microsoft365 -- m365 login --authType browser
6-
7-
# create AAD app
8-
echo "Creating AAD app..."
9-
appId=$(npx -p @pnp/cli-microsoft365 -- m365 aad app add --name "Graph Chaos Proxy Samples" --multitenant --redirectUris "http://localhost:5500/withsdk.html,http://localhost:5500/nosdk.html" --apisDelegated "https://graph.microsoft.com/User.Read.All,https://graph.microsoft.com/Presence.Read.All" --platform spa --query "appId" -o text)
10-
11-
# write app to env.js
12-
echo "Writing app to env.js..."
13-
echo "const appId = '$appId';" > env.js
14-
15-
# write app to env_esm.js
16-
echo "export const appId = '$appId';" > env_esm.js
17-
18-
echo "DONE"
1+
#!/usr/bin/env bash
2+
3+
# login
4+
echo "Sign in to Microsoft 365..."
5+
npx -p @pnp/cli-microsoft365 -- m365 login --authType browser
6+
7+
# create AAD app
8+
echo "Creating AAD app..."
9+
appId=$(npx -p @pnp/cli-microsoft365 -- m365 aad app add --name graph-chaos-proxy-samples --multitenant --redirectUris http://localhost:3000/withsdk.html,http://localhost:3000/nosdk.html --apisDelegated https://graph.microsoft.com/User.Read.All,https://graph.microsoft.com/Presence.Read.All --grantAdminConsent --platform spa --query appId -o text)
10+
11+
# write app to env.js
12+
echo "Writing app to env.js..."
13+
echo "const appId = '$appId';" > ./env.js
14+
15+
echo "DONE"

0 commit comments

Comments
 (0)