Support provider parameter in device code flow (#251767)

Not lit up on the server side, but should be ready in the next day or so.
This commit is contained in:
Tyler James Leonhardt
2025-06-17 18:20:41 -07:00
committed by GitHub
parent 13450f9689
commit 51eba2dc05

View File

@@ -330,7 +330,7 @@ class DeviceCodeFlow implements IFlow {
supportsSupportedClients: true,
supportsUnsupportedClients: true
};
async trigger({ scopes, baseUri, logger }: IFlowTriggerOptions) {
async trigger({ scopes, baseUri, signInProvider, logger }: IFlowTriggerOptions) {
logger.info(`Trying device code flow... (${scopes})`);
// Get initial device code
@@ -350,7 +350,7 @@ class DeviceCodeFlow implements IFlow {
const json = await result.json() as IGitHubDeviceCodeResponse;
const button = l10n.t('Copy & Continue to GitHub');
const button = l10n.t('Copy & Continue to {0}', signInProvider ? GitHubSocialSignInProviderLabels[signInProvider] : l10n.t('GitHub'));
const modalResult = await window.showInformationMessage(
l10n.t({ message: 'Your Code: {0}', args: [json.user_code], comment: ['The {0} will be a code, e.g. 123-456'] }),
{
@@ -364,7 +364,13 @@ class DeviceCodeFlow implements IFlow {
await env.clipboard.writeText(json.user_code);
const uriToOpen = await env.asExternalUri(Uri.parse(json.verification_uri));
let open = Uri.parse(json.verification_uri);
if (signInProvider) {
const query = new URLSearchParams(open.query);
query.set('provider', signInProvider);
open = open.with({ query: query.toString() });
}
const uriToOpen = await env.asExternalUri(open);
await env.openExternal(uriToOpen);
return await this.waitForDeviceCodeAccessToken(baseUri, json);
@@ -568,6 +574,11 @@ export const enum GitHubSocialSignInProvider {
// Apple = 'apple',
}
const GitHubSocialSignInProviderLabels = {
[GitHubSocialSignInProvider.Google]: l10n.t('Google'),
// [GitHubSocialSignInProvider.Apple]: l10n.t('Apple'),
};
export function isSocialSignInProvider(provider: unknown): provider is GitHubSocialSignInProvider {
return provider === GitHubSocialSignInProvider.Google; // || provider === GitHubSocialSignInProvider.Apple;
}