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

Catch error if no account selected in window pop up (Unhandled Promise Rejection: Error: Popup window closed) #35

Open
syedkhairi opened this issue Feb 2, 2025 · 0 comments
Assignees

Comments

@syedkhairi
Copy link

Hello!

Just wondering if possible to return error on picker:error if the retrieveAccessToken throw error. For example, if the user did not select any account when pop up window appeared, which caused [Error] Unhandled Promise Rejection: Error: Popup window closed (anonymous function) (@googleworkspace_drive-picker-element.js:91:172)

I assume adding catch and dispatch to picker:error to say no access token?

// OAuth token is required either as an attribute or from the OAuth flow using the client ID and scope
const oauthToken =
	this.getAttribute("oauth-token") ??
	(await retrieveAccessToken(
		// biome-ignore lint/style/noNonNullAssertion: just let the error bubble up when null
		this.getAttribute("client-id")!,
		this.getAttribute("scope") ??
			"https://www.googleapis.com/auth/drive.file",
	).then((token) => {
		this.dispatchEvent(
			new CustomEvent("picker:authenticated", { detail: { token } }),
		);
		return token;
	}));

At the moment, using this on Svelte, with a button state to toggle component, but if the popup window closed without account selection, no callback to reset the button state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants