[GH-ISSUE #6601] [Bug] Appimage Login #2898

Open
opened 2026-03-23 21:26:00 +00:00 by mirror · 7 comments
Owner

Originally created by @Logic-gate on GitHub (Oct 22, 2024).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/6601

Originally assigned to: @khorshuheng on GitHub.

Bug Description

When trying to login via a magic-link or OAuth, users are either sent a link via email, or taken to the said service to login through it via the browser. Both scenarios will yield an open with xdg-open when prompted.

Adding the mimetype x-scheme-handler/appflowy-flutter in .config/mimeapps.list does result in a correct link to AppFlowy when prompted.

.config/mimeapps.list

[Default Applications]
.
..
...
x-scheme-handler/appflowy-flutter=appflowy.desktop

Where appflowy.desktop is as follows:

[Desktop Entry]
Name=AppFlowy
GenericName=App Flowy Notes
Comment=Bring projects, wikis, and teams together with AI
Icon=AppFlowy
Type=Application
Categories=office;
DBusActivatable=true
SingleMainWindow=true
X-GNOME-UsesNotifications=true
X-GNOME-SingleWindow=true
Exec=PATH/TO/APPIMAGE %U
StartupNotify=false
Terminal=false
MimeType=x-scheme-handler/appflowy-flutter;

However, this will still lead to an issue where AppFlowy does not respond to the access token. Following https://github.com/AppFlowy-IO/AppFlowy/issues/5651#issuecomment-2370820785 solution, and manually grabbing the access token and executing AppFlowy will result in a buffer overflow.

The hacky way around this for magic-links is to delete both &expires_at and expires_in from the access token.

How to Reproduce

Attempt to login using the AppImage

Expected Behavior

Normal login process

Operating System

Solus OS

AppFlowy Version(s)

0.7.1

Screenshots

No response

Additional Context

No response

Originally created by @Logic-gate on GitHub (Oct 22, 2024). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/6601 Originally assigned to: @khorshuheng on GitHub. ### Bug Description When trying to login via a magic-link or OAuth, users are either sent a link via email, or taken to the said service to login through it via the browser. Both scenarios will yield an `open with xdg-open` when prompted. Adding the mimetype `x-scheme-handler/appflowy-flutter` in `.config/mimeapps.list ` does result in a correct link to AppFlowy when prompted. `.config/mimeapps.list` ``` [Default Applications] . .. ... x-scheme-handler/appflowy-flutter=appflowy.desktop ``` Where `appflowy.desktop` is as follows: ``` [Desktop Entry] Name=AppFlowy GenericName=App Flowy Notes Comment=Bring projects, wikis, and teams together with AI Icon=AppFlowy Type=Application Categories=office; DBusActivatable=true SingleMainWindow=true X-GNOME-UsesNotifications=true X-GNOME-SingleWindow=true Exec=PATH/TO/APPIMAGE %U StartupNotify=false Terminal=false MimeType=x-scheme-handler/appflowy-flutter; ``` However, this will still lead to an issue where AppFlowy does not respond to the access token. Following https://github.com/AppFlowy-IO/AppFlowy/issues/5651#issuecomment-2370820785 solution, and manually grabbing the access token and executing AppFlowy will result in a buffer overflow. The hacky way around this for magic-links is to delete both `&expires_at` and `expires_in` from the access token. ### How to Reproduce Attempt to login using the AppImage ### Expected Behavior Normal login process ### Operating System Solus OS ### AppFlowy Version(s) 0.7.1 ### Screenshots _No response_ ### Additional Context _No response_
Author
Owner

@GrahamJenkins commented on GitHub (Jan 14, 2025):

I am a linux user attempting to test appflowy and encountered this as well. I was confused about being unable to perform any editing on web and attempted to install, but am currently unable to even log in. While I see a lot of potential for a Trello/Notion clone, it doesn't give me a lot of confidence when I can't even log in and test properly.

I'll admit that I didn't go as far as to create the .desktop file, and am not familiar with the .mimeapps config, but if this is required to use the program on linux, there needs to be clear instructions on how to do this.

Or, at bare minimum provide a reasonable way to import the OAuth/email link directly into the app. Or say...support standard email/password authentication directly. At least as an option.

<!-- gh-comment-id:2589137359 --> @GrahamJenkins commented on GitHub (Jan 14, 2025): I am a linux user attempting to test appflowy and encountered this as well. I was confused about being unable to perform any editing on web and attempted to install, but am currently unable to even log in. While I see a lot of potential for a Trello/Notion clone, it doesn't give me a lot of confidence when I can't even log in and test properly. I'll admit that I didn't go as far as to create the .desktop file, and am not familiar with the .mimeapps config, but _if this is required to use the program on linux, there needs to be clear instructions on how to do this._ Or, at bare minimum provide a reasonable way to import the OAuth/email link directly into the app. Or say...support standard email/password authentication directly. At least as an *option*.
Author
Owner

@Logic-gate commented on GitHub (Jan 29, 2025):

@GrahamJenkins Since this was labelled as a bug, I am sure it'll be sorted out. I haven't tested newer versions.

<!-- gh-comment-id:2621718774 --> @Logic-gate commented on GitHub (Jan 29, 2025): @GrahamJenkins Since this was labelled as a bug, I am sure it'll be sorted out. I haven't tested newer versions.
Author
Owner

@Logic-gate commented on GitHub (Feb 2, 2025):

@GrahamJenkins Try this:

https://ki.tc/file/stream/cde22

If you want a better solution, I suggest preparing your Appimage env.

I have it setup in .local/share/appimage

You will need to add mimeapps defaults. This will map the appflowy-flutter handler to a desktop file.

in .config/mimeapps.list add the following at the bottom, under [Default Applications]


[Added Associations]
...
...
[Default Applications]
...
...
x-scheme-handler/appflowy-flutter=appflowy.desktop

in /usr/share/applications create appflowy.desktop. Make sure Exec is a full path with USER being your user.

Name=AppFlowy
GenericName=App Flowy Notes
Comment=Bring projects, wikis, and teams together with AI
Icon=AppFlowy
Type=Application
Categories=office;
DBusActivatable=true
SingleMainWindow=true
X-GNOME-UsesNotifications=true
X-GNOME-SingleWindow=true
Exec=/home/USER/.local/bin/appflowy-wrapper %U
StartupNotify=false
Terminal=false
MimeType=x-scheme-handler/appflowy-flutter;

create /home/USER/.local/bin/appflowy-wrapper and give it exec permissions.

#!/bin/bash

LOG_FILE=~/.local/share/appimage/appflowy-wrapper.log
echo "Wrapper script called with arguments: $@" | tee -a "$LOG_FILE"

# latest version
APPIMAGE_DIR=~/.local/share/appimage
APPIMAGE_PATH=$(ls -v "$APPIMAGE_DIR"/AppFlowy-*.AppImage | tail -n 1)

if [[ ! -f "$APPIMAGE_PATH" ]]; then
    echo "No AppFlowy AppImage found in $APPIMAGE_DIR" | tee -a "$LOG_FILE"
    exit 1
fi

urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }

# fix buffer overflow issue. during testing only refresh token is needed. keeping access_token before period becuase you never know
trim_url() {
    local url="$1"
    local access_token=$(echo "$url" | sed -E 's/.*access_token=([^.]*)\..*/\1/')
    local expires_at=$(echo "$url" | grep -o '&expires_at=[^&]*' || echo "")
    local expires_in=$(echo "$url" | grep -o '&expires_in=[^&]*' || echo "")
    local refresh_token=$(echo "$url" | grep -o '&refresh_token=[^&]*' || echo "")
    # new url
    echo "appflowy-flutter://#access_token=${access_token}${expires_at}${expires_in}${refresh_token}"
}

if [[ -n "$1" ]]; then
    DECODED_URL=$(urldecode "$1")
    TRIMMED_URL=$(trim_url "$DECODED_URL")
    echo "Passing the following trimmed, decoded argument to AppFlowy: $TRIMMED_URL" | tee -a "$LOG_FILE"
    nohup "$APPIMAGE_PATH" "$TRIMMED_URL" >> "$LOG_FILE" 2>&1 &
else
    echo "Launching AppFlowy without arguments" | tee -a "$LOG_FILE"
    nohup "$APPIMAGE_PATH" >> "$LOG_FILE" 2>&1 &
fi

wait $!
echo "AppFlowy has finished running." | tee -a "$LOG_FILE"

Create a dir under /home/USER/.local/share/ and name it appimage

Download whatever version of Appflowy to appimage and give it exec permissions with chmod +x

Now whenever you update Appflowy and request a magiclink, you can simply click on the redirect link from the browser and it will open the app.

This might seem as a convoluted approach, but it's a one time thing. You can change the dir to whatever you want as long as everything is linked correctly.

I hope this helps.

Cheers,

<!-- gh-comment-id:2629602268 --> @Logic-gate commented on GitHub (Feb 2, 2025): @GrahamJenkins Try this: https://ki.tc/file/stream/cde22 If you want a better solution, I suggest preparing your Appimage env. I have it setup in `.local/share/appimage` You will need to add mimeapps defaults. This will map the `appflowy-flutter` handler to a desktop file. in `.config/mimeapps.list` add the following at the bottom, under `[Default Applications]` ```txt [Added Associations] ... ... [Default Applications] ... ... x-scheme-handler/appflowy-flutter=appflowy.desktop ``` in `/usr/share/applications` create `appflowy.desktop`. Make sure Exec is a full path with USER being your user. ```config Name=AppFlowy GenericName=App Flowy Notes Comment=Bring projects, wikis, and teams together with AI Icon=AppFlowy Type=Application Categories=office; DBusActivatable=true SingleMainWindow=true X-GNOME-UsesNotifications=true X-GNOME-SingleWindow=true Exec=/home/USER/.local/bin/appflowy-wrapper %U StartupNotify=false Terminal=false MimeType=x-scheme-handler/appflowy-flutter; ``` create `/home/USER/.local/bin/appflowy-wrapper ` and give it exec permissions. ```bash #!/bin/bash LOG_FILE=~/.local/share/appimage/appflowy-wrapper.log echo "Wrapper script called with arguments: $@" | tee -a "$LOG_FILE" # latest version APPIMAGE_DIR=~/.local/share/appimage APPIMAGE_PATH=$(ls -v "$APPIMAGE_DIR"/AppFlowy-*.AppImage | tail -n 1) if [[ ! -f "$APPIMAGE_PATH" ]]; then echo "No AppFlowy AppImage found in $APPIMAGE_DIR" | tee -a "$LOG_FILE" exit 1 fi urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } # fix buffer overflow issue. during testing only refresh token is needed. keeping access_token before period becuase you never know trim_url() { local url="$1" local access_token=$(echo "$url" | sed -E 's/.*access_token=([^.]*)\..*/\1/') local expires_at=$(echo "$url" | grep -o '&expires_at=[^&]*' || echo "") local expires_in=$(echo "$url" | grep -o '&expires_in=[^&]*' || echo "") local refresh_token=$(echo "$url" | grep -o '&refresh_token=[^&]*' || echo "") # new url echo "appflowy-flutter://#access_token=${access_token}${expires_at}${expires_in}${refresh_token}" } if [[ -n "$1" ]]; then DECODED_URL=$(urldecode "$1") TRIMMED_URL=$(trim_url "$DECODED_URL") echo "Passing the following trimmed, decoded argument to AppFlowy: $TRIMMED_URL" | tee -a "$LOG_FILE" nohup "$APPIMAGE_PATH" "$TRIMMED_URL" >> "$LOG_FILE" 2>&1 & else echo "Launching AppFlowy without arguments" | tee -a "$LOG_FILE" nohup "$APPIMAGE_PATH" >> "$LOG_FILE" 2>&1 & fi wait $! echo "AppFlowy has finished running." | tee -a "$LOG_FILE" ``` Create a dir under `/home/USER/.local/share/` and name it `appimage` Download whatever version of Appflowy to `appimage` and give it exec permissions with `chmod +x` Now whenever you update Appflowy and request a magiclink, you can simply click on the redirect link from the browser and it will open the app. This might seem as a convoluted approach, but it's a one time thing. You can change the dir to whatever you want as long as everything is linked correctly. I hope this helps. Cheers,
Author
Owner

@GrahamJenkins commented on GitHub (Feb 12, 2025):

@GrahamJenkins Try this:

https://ki.tc/file/stream/cde22

If you want a better solution, I suggest preparing your Appimage env.

I have it setup in .local/share/appimage

You will need to add mimeapps defaults. This will map the appflowy-flutter handler to a desktop file.

in .config/mimeapps.list add the following at the bottom, under [Default Applications]

[Added Associations]
...
...
[Default Applications]
...
...
x-scheme-handler/appflowy-flutter=appflowy.desktop

in /usr/share/applications create appflowy.desktop. Make sure Exec is a full path with USER being your user.

Name=AppFlowy
GenericName=App Flowy Notes
Comment=Bring projects, wikis, and teams together with AI
Icon=AppFlowy
Type=Application
Categories=office;
DBusActivatable=true
SingleMainWindow=true
X-GNOME-UsesNotifications=true
X-GNOME-SingleWindow=true
Exec=/home/USER/.local/bin/appflowy-wrapper %U
StartupNotify=false
Terminal=false
MimeType=x-scheme-handler/appflowy-flutter;

create /home/USER/.local/bin/appflowy-wrapper and give it exec permissions.

#!/bin/bash

LOG_FILE=~/.local/share/appimage/appflowy-wrapper.log
echo "Wrapper script called with arguments: $@" | tee -a "$LOG_FILE"

latest version

APPIMAGE_DIR=~/.local/share/appimage
APPIMAGE_PATH=$(ls -v "$APPIMAGE_DIR"/AppFlowy-*.AppImage | tail -n 1)

if ! -f "$APPIMAGE_PATH" ; then
echo "No AppFlowy AppImage found in $APPIMAGE_DIR" | tee -a "$LOG_FILE"
exit 1
fi

urldecode() { : "${*//+/ }"; echo -e "${_//%/\x}"; }

fix buffer overflow issue. during testing only refresh token is needed. keeping access_token before period becuase you never know

trim_url() {
local url="$1"
local access_token=$(echo "$url" | sed -E 's/.access_token=([^.])../\1/')
local expires_at=$(echo "$url" | grep -o '&expires_at=[^&]
' || echo "")
local expires_in=$(echo "$url" | grep -o '&expires_in=[^&]' || echo "")
local refresh_token=$(echo "$url" | grep -o '&refresh_token=[^&]
' || echo "")
# new url
echo "appflowy-flutter://#access_token=${access_token}${expires_at}${expires_in}${refresh_token}"
}

if -n "$1" ; then
DECODED_URL=$(urldecode "$1")
TRIMMED_URL=$(trim_url "$DECODED_URL")
echo "Passing the following trimmed, decoded argument to AppFlowy: $TRIMMED_URL" | tee -a "$LOG_FILE"
nohup "$APPIMAGE_PATH" "$TRIMMED_URL" >> "$LOG_FILE" 2>&1 &
else
echo "Launching AppFlowy without arguments" | tee -a "$LOG_FILE"
nohup "$APPIMAGE_PATH" >> "$LOG_FILE" 2>&1 &
fi

wait $!
echo "AppFlowy has finished running." | tee -a "$LOG_FILE"

Create a dir under /home/USER/.local/share/ and name it appimage

Download whatever version of Appflowy to appimage and give it exec permissions with chmod +x

Now whenever you update Appflowy and request a magiclink, you can simply click on the redirect link from the browser and it will open the app.

This might seem as a convoluted approach, but it's a one time thing. You can change the dir to whatever you want as long as everything is linked correctly.

I hope this helps.

Cheers,

Thanks for the detailed instructions, I'll see if I can try this later. I see you have a workaround to resolve the buffer overflow as well, that's good to see. If course it would be nicer to see that the appimg handles these things on its own, but we'll just go one step at a time.

<!-- gh-comment-id:2655035371 --> @GrahamJenkins commented on GitHub (Feb 12, 2025): > [@GrahamJenkins](https://github.com/GrahamJenkins) Try this: > > https://ki.tc/file/stream/cde22 > > If you want a better solution, I suggest preparing your Appimage env. > > I have it setup in `.local/share/appimage` > > You will need to add mimeapps defaults. This will map the `appflowy-flutter` handler to a desktop file. > > in `.config/mimeapps.list` add the following at the bottom, under `[Default Applications]` > > [Added Associations] > ... > ... > [Default Applications] > ... > ... > x-scheme-handler/appflowy-flutter=appflowy.desktop > > in `/usr/share/applications` create `appflowy.desktop`. Make sure Exec is a full path with USER being your user. > > ``` > Name=AppFlowy > GenericName=App Flowy Notes > Comment=Bring projects, wikis, and teams together with AI > Icon=AppFlowy > Type=Application > Categories=office; > DBusActivatable=true > SingleMainWindow=true > X-GNOME-UsesNotifications=true > X-GNOME-SingleWindow=true > Exec=/home/USER/.local/bin/appflowy-wrapper %U > StartupNotify=false > Terminal=false > MimeType=x-scheme-handler/appflowy-flutter; > ``` > > create `/home/USER/.local/bin/appflowy-wrapper ` and give it exec permissions. > > #!/bin/bash > > LOG_FILE=~/.local/share/appimage/appflowy-wrapper.log > echo "Wrapper script called with arguments: $@" | tee -a "$LOG_FILE" > > # latest version > APPIMAGE_DIR=~/.local/share/appimage > APPIMAGE_PATH=$(ls -v "$APPIMAGE_DIR"/AppFlowy-*.AppImage | tail -n 1) > > if [[ ! -f "$APPIMAGE_PATH" ]]; then > echo "No AppFlowy AppImage found in $APPIMAGE_DIR" | tee -a "$LOG_FILE" > exit 1 > fi > > urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } > > # fix buffer overflow issue. during testing only refresh token is needed. keeping access_token before period becuase you never know > trim_url() { > local url="$1" > local access_token=$(echo "$url" | sed -E 's/.*access_token=([^.]*)\..*/\1/') > local expires_at=$(echo "$url" | grep -o '&expires_at=[^&]*' || echo "") > local expires_in=$(echo "$url" | grep -o '&expires_in=[^&]*' || echo "") > local refresh_token=$(echo "$url" | grep -o '&refresh_token=[^&]*' || echo "") > # new url > echo "appflowy-flutter://#access_token=${access_token}${expires_at}${expires_in}${refresh_token}" > } > > if [[ -n "$1" ]]; then > DECODED_URL=$(urldecode "$1") > TRIMMED_URL=$(trim_url "$DECODED_URL") > echo "Passing the following trimmed, decoded argument to AppFlowy: $TRIMMED_URL" | tee -a "$LOG_FILE" > nohup "$APPIMAGE_PATH" "$TRIMMED_URL" >> "$LOG_FILE" 2>&1 & > else > echo "Launching AppFlowy without arguments" | tee -a "$LOG_FILE" > nohup "$APPIMAGE_PATH" >> "$LOG_FILE" 2>&1 & > fi > > wait $! > echo "AppFlowy has finished running." | tee -a "$LOG_FILE" > > Create a dir under `/home/USER/.local/share/` and name it `appimage` > > Download whatever version of Appflowy to `appimage` and give it exec permissions with `chmod +x` > > Now whenever you update Appflowy and request a magiclink, you can simply click on the redirect link from the browser and it will open the app. > > This might seem as a convoluted approach, but it's a one time thing. You can change the dir to whatever you want as long as everything is linked correctly. > > I hope this helps. > > Cheers, Thanks for the detailed instructions, I'll see if I can try this later. I see you have a workaround to resolve the buffer overflow as well, that's good to see. If course it would be nicer to see that the appimg handles these things on its own, but we'll just go one step at a time.
Author
Owner

@VladKilliakov commented on GitHub (Mar 9, 2025):

@GrahamJenkins I experienced the same issue as the OP leading to being unable to logic using magic link on Linux (Ubuntu 24.10). I tried the approach that you described and it fixed the issue for me!

Hopefully, the future versions of the app will add proper integration of this into the AppImage executable as well. I'd be happy to help out with this as well, if any help is needed.

<!-- gh-comment-id:2709128216 --> @VladKilliakov commented on GitHub (Mar 9, 2025): @GrahamJenkins I experienced the same issue as the OP leading to being unable to logic using magic link on Linux (Ubuntu 24.10). I tried the approach that you described and it fixed the issue for me! Hopefully, the future versions of the app will add proper integration of this into the AppImage executable as well. I'd be happy to help out with this as well, if any help is needed.
Author
Owner

@Logic-gate commented on GitHub (Mar 12, 2025):

Hopefully, the future versions of the app will add proper integration of this into the AppImage executable as well. I'd be happy to help out with this as well, if any help is needed.

@VladKilliakov In my opinion, the ideal way to fix this issue is via identifying and patching the buffer overflow issue. We can then focus on the xdg handler definition for proper xdg-open.

If however the devs decide to patch the custom wrapper script to handle argument pass through, I'll have a look as to how we can add the wrapper script in the Appimage.

@annieappflowy ping.

<!-- gh-comment-id:2718455807 --> @Logic-gate commented on GitHub (Mar 12, 2025): > Hopefully, the future versions of the app will add proper integration of this into the AppImage executable as well. I'd be happy to help out with this as well, if any help is needed. @VladKilliakov In my opinion, the ideal way to fix this issue is via identifying and patching the buffer overflow issue. We can then focus on the xdg handler definition for proper xdg-open. If however the devs decide to patch the custom wrapper script to handle argument pass through, I'll have a look as to how we can add the wrapper script in the Appimage. @annieappflowy ping.
Author
Owner

@Logic-gate commented on GitHub (Mar 23, 2025):

Possible cause and potential fix.

This might be related to a bug in AppImage's runtime. There's an open PR(https://github.com/AppImage/type2-runtime/pull/38).

As for the MIME Type handler. I suggest a post install script that installs the desktop files and adds adequate scheme handling. The desktop file and icon should be in the AppDir.

<!-- gh-comment-id:2746307995 --> @Logic-gate commented on GitHub (Mar 23, 2025): Possible cause and potential fix. This might be related to a bug in AppImage's runtime. There's an open PR(https://github.com/AppImage/type2-runtime/pull/38). As for the MIME Type handler. I suggest a post install script that installs the desktop files and adds adequate scheme handling. The desktop file and icon should be in the AppDir.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#2898
No description provided.