diff --git a/packages/fx-core/src/common/tools.ts b/packages/fx-core/src/common/tools.ts index 6a431beec7..36f539a66d 100644 --- a/packages/fx-core/src/common/tools.ts +++ b/packages/fx-core/src/common/tools.ts @@ -44,14 +44,22 @@ export async function getSPFxToken( // this function will be deleted after VS has added get dev tunnel and list dev tunnels API const TunnelManagementUserAgent = { name: "Teams-Toolkit" }; -export async function listDevTunnels(token: string): Promise> { +export async function listDevTunnels( + token: string, + isGitHub = false +): Promise> { try { const tunnelManagementClientImpl = new TunnelManagementHttpClient( TunnelManagementUserAgent, ManagementApiVersions.Version20230927preview, () => { - const res = `Bearer ${token}`; - return Promise.resolve(res); + if (isGitHub === true) { + const res = `github client_id=a200baed193bb2088a6e ${token}`; + return Promise.resolve(res); + } else { + const res = `Bearer ${token}`; + return Promise.resolve(res); + } } ); diff --git a/packages/fx-core/tests/common/tools.test.ts b/packages/fx-core/tests/common/tools.test.ts index a59e1474c5..d8a9559c39 100644 --- a/packages/fx-core/tests/common/tools.test.ts +++ b/packages/fx-core/tests/common/tools.test.ts @@ -326,6 +326,20 @@ projectId: 00000000-0000-0000-0000-000000000000`; }); }); + describe("listDevTunnels using github token", () => { + const sandbox = sinon.createSandbox(); + afterEach(() => { + sandbox.restore(); + }); + + it("should return an error when the API call fails", async () => { + const token = "test-token"; + + const result = await listDevTunnels(token, true); + chai.assert.isTrue(result.isErr()); + }); + }); + describe("isUserCancelError()", () => { it("should return true if error is UserCancelError", () => { const error = new Error(); diff --git a/packages/server/src/serverConnection.ts b/packages/server/src/serverConnection.ts index e5207a6942..1e4db860a5 100644 --- a/packages/server/src/serverConnection.ts +++ b/packages/server/src/serverConnection.ts @@ -418,7 +418,7 @@ export default class ServerConnection implements IServerConnection { const corrId = inputs.correlationId ? inputs.correlationId : ""; const res = await Correlator.runWithId( corrId, - (params) => listDevTunnels(inputs.devTunnelToken), + (params) => listDevTunnels(inputs.devTunnelToken, inputs.isGitHub), inputs ); return standardizeResult(res);