Skip to content

API token should be fetched later #104

@koppor

Description

@koppor

JabRef uses Java Key Ring to connect to password stores.

org.jabref.preferences.JabRefPreferences#getAiPreferences access that key store when creating the AI Chat tab. This leads to following startup error output:

2024-08-04 10:50:20 [JavaFX Application Thread] org.jabref.preferences.JabRefPreferences.getAiApiTokenFromKeyring()
WARN: JabRef could not open keyring for retrieving OpenAI API token: com.github.javakeyring.PasswordAccessException: Error code 1168
        at java.keyring@1.0.4/com.github.javakeyring.internal.windows.WinCredentialStoreBackend.getPassword(WinCredentialStoreBackend.java:61)
        at java.keyring@1.0.4/com.github.javakeyring.Keyring.getPassword(Keyring.java:90)
        at org.jabref@100.0.0/org.jabref.preferences.JabRefPreferences.getAiApiTokenFromKeyring(JabRefPreferences.java:2808)
        at org.jabref@100.0.0/org.jabref.preferences.JabRefPreferences.getAiPreferences(JabRefPreferences.java:2773)
        at org.jabref@100.0.0/org.jabref.gui.JabRefGUI.initialize(JabRefGUI.java:159)
        at org.jabref@100.0.0/org.jabref.gui.JabRefGUI.start(JabRefGUI.java:90)
        at javafx.graphics@22.0.2/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
        at javafx.graphics@22.0.2/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
        at javafx.graphics@22.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
        at javafx.graphics@22.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
        at javafx.graphics@22.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at javafx.graphics@22.0.2/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics@22.0.2/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
        at java.base/java.lang.Thread.run(Thread.java:1583)
2024-08-04 10:50:21 [JavaFX Application Thread] org.jabref.gui.StateManager.setActiveDatabase()

When opening preferences, the key is there.


When using Gnome, on startup, one will be asked to open the key store. This is not necessary. It is necessary when interacting with the AI.

Please postpone the call to org.jabref.preferences.JabRefPreferences#getAiApiTokenFromKeyring to the latest point in time (and store the key internally once retrieved). (OK, one also has to take care if they key is changed by the user)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions