rafaelmardojai / forge-sparks

Get git forges notifications
MIT License
61 stars 7 forks source link

Error when adding Gitea account with access token that lacks `read:user` permission #12

Closed jibsaramnim closed 10 months ago

jibsaramnim commented 10 months ago

Adding a Gitea instance with an access token that just has the notifications permission results in "Unexpected error when creating the account" being shown in the app. The log shows:

com.mardojai.ForgeSparks-Message: 10:24:46.276: Error: Expected type string for argument 'value' but got type undefined
createCheckedMethod/<@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:730:46
saveAccount@resource:///com/mardojai/ForgeSparks/model/accountsManager.js:165:33
async*_onAddAccount@resource:///com/mardojai/ForgeSparks/preferences.js:399:28
Async*main@resource://com/mardojai/ForgeSparks/main.js:28:24
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
@file:///app/bin/forge-sparks:28:43
@file:///app/bin/forge-sparks:34:6

The app did actually save the newly added account, though it only seems to show up when quitting and re-opening the app. It then also shows up in the Accounts list with a missing username, which also exposes the root if the issue; when also giving access to the read:user permission, everything works exactly as expected.

_(Thanks so much for building this app! I'm giving it a try to see if I can maybe finally stop getting so many darn emails from Github :sweatsmile:)

rafaelmardojai commented 10 months ago

This is documented for GitHub, looks like I forgot that for Gitea 😅.

Also, the account creation shouldn’t happen after the error, I need to fix that.

rafaelmardojai commented 10 months ago

Ugh, and seems like now we also need read:issue to get the notifications subject details (like the html url, and open/close status) even for public repos.

jibsaramnim commented 10 months ago

(...) seems like now we also need read:issue to get the notifications subject details (...)

Is that only for Gitea (and I presume Forgejo) or also GitHub?

rafaelmardojai commented 10 months ago

GitHub requires full repo scope but only for private repos (see #10), that's already documented in the development version.

jibsaramnim commented 10 months ago

Got it. I saw that one come by too yeah. Thank you!

rafaelmardojai commented 10 months ago

The app now should completely fail to add an account if basic scopes are not granted (read:user and read:notification).

Without read:issue and write:notification the app should be pretty usable, but any way, those scopes are also documented now.