Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My extension broke the account menu #117463

Closed
roblourens opened this issue Feb 23, 2021 · 3 comments
Closed

My extension broke the account menu #117463

roblourens opened this issue Feb 23, 2021 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@roblourens
Copy link
Member

Testing #117299

I have a simple auth provider that returns an empty array for getSessions. When I click the Accounts menu in the activity bar, nothing happens. When my auth provider is not registered, then it opens up and shows my github and msft accounts as usual.

recording (2)

Here's my extension code:

export async function activate(context: vscode.ExtensionContext) {
	context.subscriptions.push(vscode.commands.registerCommand('extension.helloWorld', async () => {
		const s = await vscode.authentication.getSession('testAuthProvider', ['some scope'], { createIfNone: true });
		console.log(`Got ${s}`);
	}));
	vscode.authentication.registerAuthenticationProvider('testAuthProvider', 'My Cool Auth Provider', new AuthProvider());
}

class AuthProvider implements vscode.AuthenticationProvider {
	private _onDidChangeSessions: vscode.EventEmitter<vscode.AuthenticationProviderAuthenticationSessionsChangeEvent> = new vscode.EventEmitter();
	onDidChangeSessions: vscode.Event<vscode.AuthenticationProviderAuthenticationSessionsChangeEvent> = this._onDidChangeSessions.event;

	async getSessions(): Promise<readonly vscode.AuthenticationSession[]> {
		console.log(`getSessions`);
		return [];
	}

	async createSession(scopes: string[]): Promise<vscode.AuthenticationSession> {
		console.log(`createSession ${scopes}`);
		return {
			accessToken: 'accessToken',
			account: {
				id: 'me',
				label: 'My Account'
			},
			id: 'sessionId',
			scopes: [...scopes, 's1']
		};
	}

	async removeSession(sessionId: string): Promise<void> {
		console.log(`removeSession: ${sessionId}`);
	}
}
@roblourens
Copy link
Member Author

Even if I return some session, it seems like the same thing happens.

@roblourens
Copy link
Member Author

I noticed this error in devtools:

image

But there is an auth provider with that id...

@RMacfarlane
Copy link
Contributor

Ah, there's also a way to add a package.json contribution declaring an auth provider, which I was using to populate a list of auth providers immediately on vscode.authentication. That API didn't make it into stable but there are some traces of it I need to remove, this was trying to use the label from that. Nice catch!

@RMacfarlane RMacfarlane added the bug Issue identified by VS Code Team member as probable bug label Feb 23, 2021
@RMacfarlane RMacfarlane added this to the February 2021 milestone Feb 23, 2021
@roblourens roblourens added the verified Verification succeeded label Feb 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants
@roblourens @RMacfarlane and others