PopClip-Extensions icon indicating copy to clipboard operation
PopClip-Extensions copied to clipboard

API Key Not Saving in Keychain - OpenAI Chat Extension

Open peixinshen opened this issue 1 year ago • 2 comments
trafficstars

Thank you for developing and maintaining this great extension!

I am using the "OpenAI Chat" extension with PopClip on MacOS Sequoia 15.1. Since the 2024-05-17 update (v133), where the API key is stored in the keychain, the API key cannot save properly. After entering the key in the settings, it appears blank when reopened. Using this extension warns: Message from OpenAl (code 401): You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth. I tried to revert the API key type from "secret" back to "string" in Config.ts and found that it resolved the issue.

Could this be a bug, or am I missing the correct way to store the API key in the keychain? Thanks for your help!

peixinshen avatar Aug 23 '24 08:08 peixinshen

Same Problem

Florianismeandonlyme avatar Aug 27 '24 13:08 Florianismeandonlyme

When I revert the API key type in Config.ts to string, I can't start this extension. My version of the extension is 244.

ziegn avatar Oct 16 '24 08:10 ziegn

This one is currently a mystery to me. I don't think it is an issue with the extension but rather it seems PopClip may be having a problem saving to the keychain on some people's machines. As an initial step to gather information about the problem, I've added an alert dialog when a keychain action fails in PopClip 2024.12 (released today). If you see such an alert, please let me know the error message details.

pilotmoon avatar Dec 19 '24 19:12 pilotmoon

When I revert the API key type in Config.ts to string, I can't start this extension. My version of the extension is 244.

If you're editing an extension you'll need to also change the identifier so that is does not start with com.pilotmoon. -- then is should start OK. If any trouble please let me know the specifi eror or whatever (in a different issue, or an email)

pilotmoon avatar Dec 19 '24 19:12 pilotmoon

This one is currently a mystery to me. I don't think it is an issue with the extension but rather it seems PopClip may be having a problem saving to the keychain on some people's machines. As an initial step to gather information about the problem, I've added an alert dialog when a keychain action fails in PopClip 2024.12 (released today). If you see such an alert, please let me know the error message details.

Thanks for the update! Here is the error that popped up in PopClip 2024.12.

Keychain Error
Function : Secltem Add , Error code : -34018 , DP : 1 , Sync : 0 , Service : com.pilotmoon.popclip , Identifier : extension # com.pilotmoon.popclip.exten-
sion.chatgpt # apikey , DataLen : 56

peixinshen avatar Dec 24 '24 15:12 peixinshen

Thank you.

That error -34018 is errSecMissingEntitlement. Something to do with entitlements and code signing.

Are you using a cracked version of PopClip?

pilotmoon avatar Dec 25 '24 07:12 pilotmoon

Thank you.

That error -34018 is errSecMissingEntitlement. Something to do with entitlements and code signing.

Are you using a cracked version of PopClip?

Now I have completely reinstalled the licensed version of PopClip. Everything works perfectly: the API key can be saved without any warnings. Thank you very much for developing and maintaining this excellent extension!

peixinshen avatar Dec 25 '24 12:12 peixinshen

That's great. Yes, a clean reinstall should solve it. If there is any modification or damage to the PopClip.app package, that will prevent macOS verifying the app signature and it won't allow it to access the secure keychain.

pilotmoon avatar Dec 27 '24 09:12 pilotmoon

The bug seems not fixed yet :(

yslin1995 avatar Mar 13 '25 07:03 yslin1995

@yslin1995 It's not a bug. It's a corrupted signature of your app.

Did you try reinstalling a fresh official copy of PopClip (not a cracked version), from the PopClip web site?

pilotmoon avatar Mar 13 '25 08:03 pilotmoon

@yslin1995 It's not a bug. It's a corrupted signature of your app.

Did you try reinstalling a fresh official copy of PopClip (not a cracked version), from the PopClip web site?

Yep, still encounters the error code 401, but when I go to the setting, the API KEY becomes blank.

yslin1995 avatar Mar 13 '25 09:03 yslin1995

What version of PopClip?

pilotmoon avatar Mar 13 '25 14:03 pilotmoon

2024.5.2

yslin1995 avatar Mar 13 '25 14:03 yslin1995

Please update to version 2024.12

pilotmoon avatar Mar 13 '25 14:03 pilotmoon