API key error message

116 views
Skip to first unread message

Steve Blair

unread,
Apr 1, 2020, 3:56:25 PM4/1/20
to Freesound API
Hi Freesound!
I'm having some difficulty getting the API key to work. Attached is an image showing the error message when I run examples.py with the API_key replaced.

Thanks!
Steve
Screen Shot 2020-04-01 at 3.53.16 PM.png

Frederic Font Corbera

unread,
Apr 2, 2020, 2:28:43 AM4/2/20
to freeso...@googlegroups.com
Hi,

The way to pass the api key in the example is to set it as an environment variable named "FREESOUND_API_KEY" (see message on screen). What you have done is to replace the "FREESOUND_API_KEY" string for your api key. The whole point of this is that your specific key is not hardcoded in the file so, for example, you can commit the file to a repository and it does not contain the "secret". The python function os.getenv gets and environment variable with the provided name. What you're trying to do is to get an environment variable named "XgAJ..." instead of one named "FREESOUND_API_KEY". You can also hardcode your api key in the example file, but you should do it using the freesound_client.set_token function, not os.getenv. Your possible solutions are:

1) Set the env variable before running the script, eg "export FREESOUND_API_KEY=YOUR_API_KEY; python examples.py"
2) set api_key="YOUR_API_KEY" instead of trying to retrieve it from the environment using os.getenv

Hope this helps,

Cheers,

frederic

--
Frederic Font - ffont.github.io
Music Technology Group, UPF - mtg.upf.edu
Freesound - freesound.org



--

---
You received this message because you are subscribed to the Google Groups "Freesound API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to freesound-ap...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/freesound-api/2d2162ff-3b19-441c-834d-6f400c3f5fdc%40googlegroups.com.

Steve Blair

unread,
Apr 2, 2020, 10:47:58 AM4/2/20
to Freesound API
Great thanks for your help Frederic.
To unsubscribe from this group and stop receiving emails from it, send an email to freeso...@googlegroups.com.

Esteban Agosin Otero

unread,
Dec 1, 2021, 6:31:11 PM12/1/21
to Freesound API
Hi Steve, Could you resolve it? I am stuck in the place
Reply all
Reply to author
Forward
0 new messages