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

Sync function not working in some language env #512

Closed
HoneyLuka opened this issue Jul 17, 2024 · 3 comments · Fixed by #513
Closed

Sync function not working in some language env #512

HoneyLuka opened this issue Jul 17, 2024 · 3 comments · Fixed by #513
Labels

Comments

@HoneyLuka
Copy link
Contributor

HoneyLuka commented Jul 17, 2024

Actual Behavior

Both Google Drive and Dropbox is not working in ko env

uBlacklist sync with Dropbox
uBlacklist sync with Dropbox - Error

Steps to Reproduce the Problem

as shown above, the key point is the callback url is mismatch

The correct url is https://iorate.github.io/ublacklist/callback
But in ko env, it change to https://iorate.github.io/ublacklist/ko/callback

I suggest user to change browser language to en, it solved the problem.

  • Language: ko
aug-dev added a commit to aug-dev/ublacklist-experiments that referenced this issue Jul 21, 2024
…orate#512)

When trying to perform an OAuth flow to enable synchronization, there is a need
to redirect to an URL in the iorate.github.io/ublacklist/ website to finish
the process.

The extension was wrongfully redirecting to pages localized pages that don't
exist yet.
@aug-dev
Copy link
Contributor

aug-dev commented Jul 21, 2024

Hey there.

After some investigation, I found that this issue is mainly being caused by two things:

  • A problem with a getWebsiteURL() function that returns a localized version of the callback page that doesn't exist.
  • The Korean page is not registered as a redirect_uri on the OAuth configurations for Dropbox and Google Drive. (This is probably true for other locales too.)

The second thing is something that only iorate can fix by adding the URLs to the respective App Consoles.

Considerations about the second option

I think that adding a page that doesn't exist to the redirect_uris is probably not a good idea, since it would probably be better to se the English version than a Page Not Found 404 message.

Although, to be fair, the page is not even seen by the user if everything goes well, so it probably would matter that much.

Code changes

The current version of the function returns a localized version of the callback page, but the problem is that it checks for the extension's i18n files, not the website's.

This is a problem because even though the extension itself has a Korean version, the documentation website doesn't.

export function getWebsiteURL(path: string): string {
const locale = translate("websiteLocale");
return `https://iorate.github.io/ublacklist${
locale === "en" ? "" : `/${locale}`
}${path.startsWith("/") ? "" : "/"}${path}`;
}

I added this extra condition, and after some basic testing, it seems that the issue is fixed (I tested only on Dropbox):

https://github.com/aug-dev/ublacklist-experiments/blob/ede7037d2152276e752a0e5172e5da6bb63ab57a/src/scripts/locales.ts#L19-L26

I haven't made a PR yet because the solution is still somewhat crude, since the localized values are hard-coded (which is not ideal).

I will try to come up with something better, but if @iorate beats me to it, I hope this can be of some help.

@iorate
Copy link
Owner

iorate commented Jul 21, 2024

@HoneyLuka @aug-dev I appreciate your report and investigation.

I think the problem is located here:

websiteLocale: "ko",

Since this entry is translated despite the lack of a Korean translation of the website, translate("websiteLocale") returns "ko" and getWebsiteURL("/callback") returns "https://iorate.github.io/ublacklist/ko/callback", which does not exist.

Copy link

🎉 This issue has been resolved in version 8.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants