Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/sanity/src/githubAuth.ts
5241 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Browser, Page } from 'playwright';
7
import { TestContext } from './context.js';
8
9
/**
10
* Handles GitHub authentication flows in the browser.
11
*/
12
export class GitHubAuth {
13
// private readonly username = process.env.GITHUB_ACCOUNT;
14
// private readonly password = process.env.GITHUB_PASSWORD;
15
16
public constructor(private readonly context: TestContext) { }
17
18
/**
19
* Runs GitHub device authentication flow in a browser.
20
* @param browser Browser to use.
21
* @param code Device authentication code to use.
22
*/
23
public async runDeviceCodeFlow(browser: Browser, code: string) {
24
this.context.log(`Running GitHub device flow with code ${code}`);
25
const page = await browser.newPage();
26
await page.goto('https://github.com/login/device');
27
}
28
29
/**
30
* Runs GitHub user authentication flow in the browser.
31
* @param page Authentication page.
32
*/
33
public async runUserWebFlow(page: Page) {
34
this.context.log(`Running GitHub browser flow at ${page.url()}`);
35
}
36
}
37
38