diff --git a/extensions/github-authentication/src/flows.ts b/extensions/github-authentication/src/flows.ts index a6922c22dc8..0c470b1d65d 100644 --- a/extensions/github-authentication/src/flows.ts +++ b/extensions/github-authentication/src/flows.ts @@ -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; }