How can I make calls to spotify api- I want to get episodes listed of a podcast.

There is a problem related to bearer token. I dont even know how to start writing the code
20 Replies
JOY
JOYOP•17mo ago
Ive watched videos but its not working
Jochem
Jochem•17mo ago
There's extensive documentation on the Spotify developer site, including examples. If you get stuck using those, post your code and error messages, and someone might be able to help
JOY
JOYOP•17mo ago
this is the part of code
JOY
JOYOP•17mo ago
error
JOY
JOYOP•17mo ago
the id of show is correct tho
Jochem
Jochem•17mo ago
You have to define (I think in the Spotify admin panel) what your application can access, did you set that up?
JOY
JOYOP•17mo ago
Yes the URI is defined in the panel - localhost:3000 I just can't figure out 😞
JOY
JOYOP•17mo ago
Bro i read the docs , but i dont understand one thing -what if we dont want to authorize? Im making a podcast website for someone and i want users to stream the episodes without logging in in spotify Am i clear enough idk? feels like shouldn't have taken this project in the first place, fkin suck at codin
Jochem
Jochem•17mo ago
The user doesn't authorize themselves, but you have to authorize using a single account to use the api. It's probably also a bad idea because of that to run it on the front end, because I don't think you want to expose your api key to the user
JOY
JOYOP•17mo ago
ohh yes the key was just temporarily there, was goin to create .env after fixing the issue
Jochem
Jochem•17mo ago
if your code runs frontend, adding a .env won't fix anything
JOY
JOYOP•17mo ago
I dont understand
Jochem
Jochem•17mo ago
you posted this in #front-end, which means you're running all your code in the browser right? Just uploading it to a static site somewhere that serves the files and doesn't run any code itself? In that case, the values in that .env file are just going to go through the bundler and straight into the javascript file that's getting sent to the user .env isn't magic security. If the code runs in the browser, the user will be able to get the API key with minimal effort
JOY
JOYOP•17mo ago
what im supposed to do then, im using astro
Jochem
Jochem•17mo ago
do enough research into what people can do with the API key to see if you're comfortable having it public, or write a backend somewhere that lets you retain control of the key
JOY
JOYOP•17mo ago
ok
JOY
JOYOP•17mo ago
APII have an api call in app.js- there's a episodeName variable in async 'main' function The variable is console logging the value of name of episodes retrieved by the api. img2: I want to print those values in episodelist.astro page Output: image3 So I want episodelist.astro to be an index for the episode, how can i print the values
Jochem
Jochem•17mo ago
make a new post, this is an entirely different question. And please, whenever possible, include your actual code and not just screenshots @joy2op
JOY
JOYOP•17mo ago
my bad G, sure done
Want results from more Discord servers?
Add your server