Skip to content

Commit

Permalink
Merge pull request #1231 from OfficeDev/zhaofeng/proxy/readme
Browse files Browse the repository at this point in the history
fix(devproxy): update readme
  • Loading branch information
eriolchan authored Mar 25, 2024
2 parents e8cd891 + b55610d commit b78fc79
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion graph-toolkit-contact-exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Graph Toolkit Contact Exporter sample APP provides an easy way to export your te

### Run the app locally with proxy
In some scenarios, it is helpful to skip the login and authentication flow and then provide mocked Graph API responses for development and test purpose. This sample provides a new way to debug it with proxy for mocking Graph API responses. You can customize the desired Graph API responses.
1. Refer to [Get started with Dev Proxy](https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/get-started?tabs=powershell&pivots=client-operating-system-windows) to install devproxy first
1. Refer to [Get started with Dev Proxy](https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/get-started?tabs=powershell&pivots=client-operating-system-windows) to install devproxy first.
1. Open the project with VS Code, open the `Run and Debug Activity` Panel and select `Debug in Teams with proxy (Edge)`.
1. Please refer to [Proxy Mode](proxy/README.md) for more information.

Expand Down
9 changes: 7 additions & 2 deletions graph-toolkit-contact-exporter/proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ To run the app locally with Graph API proxy, you can skip the user login flow an
## How it works

- From VS Code:
1. In `.vscode.tasks.json`, add the `Check dev proxy` task to ensure the `devproxy` command available.
2. In `.vscode.tasks.json`, set environment `REACT_APP_HOOK_FOR_PROXY` in `Start frontend with proxy` task to enable the hooking code.
1. In `.vscode/tasks.json`, add the `Check dev proxy` task to ensure the `devproxy` command available.
2. In `.vscode/tasks.json`, set environment `REACT_APP_HOOK_FOR_PROXY` in `Start frontend with proxy` task to enable the hooking code.
3. Add the `Start dev proxy` task to start the devproxy. It leverages the package script command `proxy:teamsfx`.

When the app is running, the authentication flow for login and get access token will be hooked to skip. The Graph API requests will be sent to the devproxy listening address(127.0.0.1:54000).
Expand All @@ -28,3 +28,8 @@ Refer to [Simulate errors](https://learn.microsoft.com/en-us/microsoft-cloud/dev
To get the minimal permission for Graph API, launch the app by `Debug in Teams with proxy (Edge)` in VS Code and test the app by calling all the Graph API requests, then switch to the `Start dev proxy` task window and input S, the devproxy will print the minimal permissions in the output.
Refer to [Detect minimal Microsoft Graph API permissions](https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/how-to/detect-minimal-microsoft-graph-api-permissions) to learn more.

## Known issues
### Launch failed for devproxy not found in MacOS
In MacOS, it may fail to run the app locally with proxy for devproxy not found even if the devproxy has already been installed. Because the `Check dev proxy` and `Start dev proxy` depend on the `VS Code` custom tasks execution mechanism. As the default task shell is `/bin/sh` for VS Code in MacOS, the PATH set by devproxy installation may not take effect for it. To make sure `Check dev proxy` and `Start dev proxy` can be executed successfully, you can set the PATH of devproxy in `/etc/paths` or other files which can make the `/bin/sh` find the devproxy.


2 changes: 1 addition & 1 deletion hello-world-tab-with-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Hello World Tab with Backend shows you how to build a tab app with an Azure Func

### Run the app locally with proxy
In some scenarios, it is helpful to skip the login and authentication flow and then provide mocked Graph API responses for development and test purpose. This sample provides a new way to debug it with proxy for mocking Graph API responses. You can customize the desired Graph API responses.
1. Refer to [Get started with Dev Proxy](https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/get-started?tabs=powershell&pivots=client-operating-system-windows) to install devproxy first
1. Refer to [Get started with Dev Proxy](https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/get-started?tabs=powershell&pivots=client-operating-system-windows) to install devproxy first.
1. Open the project with VS Code, open the `Run and Debug Activity` Panel and select `Debug in Teams with proxy (Edge)`.
1. Please refer to [Proxy Mode](proxy/README.md) for more information.

Expand Down
8 changes: 6 additions & 2 deletions hello-world-tab-with-backend/proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ To run the app locally with Graph API proxy, you can skip the user login flow an
## How it works

- From VS Code:
1. In `.vscode.tasks.json`, add the `Check dev proxy` task to ensure the `devproxy` command available.
1. In `.vscode.tasks.json`, set environment `REACT_APP_HOOK_FOR_PROXY` in `Start frontend with proxy` task and `HOOK_FOR_PROXY` in `Start backend with proxy` task to enable the hooking code.
1. In `.vscode/tasks.json`, add the `Check dev proxy` task to ensure the `devproxy` command available.
1. In `.vscode/tasks.json`, set environment `REACT_APP_HOOK_FOR_PROXY` in `Start frontend with proxy` task and `HOOK_FOR_PROXY` in `Start backend with proxy` task to enable the hooking code.
1. Add the `Start dev proxy` task to start the devproxy. It leverages the package script command `proxy:teamsfx`.

When the app is running, the authentication flow for login and get access token will be hooked to skip. The Graph API requests will be sent to the devproxy listening address(127.0.0.1:54000).
Expand All @@ -29,3 +29,7 @@ Refer to [Simulate errors](https://learn.microsoft.com/en-us/microsoft-cloud/dev
To get the minimal permission for Graph API, launch the app by `Debug in Teams with proxy (Edge)` in VS Code and test the app by calling all the Graph API requests, then switch to the `Start dev proxy` task window and input S, the devproxy will print the minimal permissions in the output.
Refer to [Detect minimal Microsoft Graph API permissions](https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/how-to/detect-minimal-microsoft-graph-api-permissions) to learn more.

## Known issues
### Launch failed for devproxy not found in MacOS
In MacOS, it may fail to run the app locally with proxy for devproxy not found even if the devproxy has already been installed. Because the `Check dev proxy` and `Start dev proxy` depend on the `VS Code` custom tasks execution mechanism. As the default task shell is `/bin/sh` for VS Code in MacOS, the PATH set by devproxy installation may not take effect for it. To make sure `Check dev proxy` and `Start dev proxy` can be executed successfully, you can set the PATH of devproxy in `/etc/paths` or other files which can make the `/bin/sh` find the devproxy.

0 comments on commit b78fc79

Please sign in to comment.