spotify-web-api-node | A Node.js wrapper for Spotify 's Web API | Runtime Evironment library
kandi X-RAY | spotify-web-api-node Summary
kandi X-RAY | spotify-web-api-node Summary
This is a universal wrapper/client for the Spotify Web API that runs on Node.JS and the browser, using browserify/webpack/rollup. A list of selected wrappers for different languages and environments is available at the Developer site's Libraries page. Project owners are thelinmichael and JMPerez, with help from a lot of awesome contributors.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spotify-web-api-node
spotify-web-api-node Key Features
spotify-web-api-node Examples and Code Snippets
Community Discussions
Trending Discussions on spotify-web-api-node
QUESTION
Any other requests through my react app seems to be working fine, until I try to res.redirect
to somewhere else.
I somewhat understand why it does not work, but I cant figure out how to properly implement something similar to that.
Code for references:
React app.js:
...ANSWER
Answered 2021-Mar-20 at 21:04Step one to avoid CORS issues is to make sure your website on Spotify is 'localhost:4000'.
The redirect is most likely causing the concern. You don't want to use a redirect. You want Spotify to authenticate the user and then redirect them back to your website with a token.
I would suggest using passportJS, this is a much more secure way if you are new to handling tokens and such.
Create a strategy as such
QUESTION
EDIT
Check this module for managing the authentication: https://www.npmjs.com/package/passport-spotify
There is an example with working code for NodeJs to start from.
To get user preferences, etc. check out this module which can be combined with the one above: https://www.npmjs.com/package/spotify-web-api-node
Check out the following example on how I have done it:
...ANSWER
Answered 2021-Jan-14 at 21:07This helped:
Passport-Spotify Passport strategy for authenticating with Spotify using the OAuth 2.0 API.
This module lets you authenticate using Spotify in your Node.js applications. By plugging into Passport, Spotify authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
For more information about Spotify's OAuth 2.0 implementation, check their Web API Authorization Guide.
Installation $ npm install passport-spotify
QUESTION
I have a React app in Electron, and I'm trying to access the spotify API using the spotify-web-api-node library. However, I'm not sure exactly how the oauth flow is meant to work inside of an Electron app... Firstly, for the redirect URL, I used this question and added a registerFileProtocol
call to my file. Then I added a specific ipcMain.on
handler for receiving the spotify login call from a page, which I've confirmed works with console logs. However, when I get to actually calling the authorizeURL
, nothing happens?
This is part of my main.js:
...ANSWER
Answered 2020-Dec-07 at 12:22In a desktop app it is recommended to open the system browser, and the Spotify login page will render there, as part of creating a promise. The opener library can be used to invoke the browser.
When the user has finished logging in, the technique is to receive the response via a Private URI Scheme / File Protocol, then to resolve the promise, get an authorization code, then swap it for tokens. It is tricky though.
RESOURCES OF MINE
I have some blog posts on this, which you may be able to borrow some ideas from, and a couple of code samples you can run on your PC:
The second of these is a React app and uses a Private URI scheme, so is fairly similar to yours. I use the AppAuth-JS library and not Spotify though.
QUESTION
I'm using the spotify-web-api-node and when I do api calls, the returned data looks like that in the console:
...ANSWER
Answered 2020-Oct-26 at 13:52You can use console.log(JSON.stringify(data.body, null, 2))
.
That prints JSON in tree without losing its content like you see in [Object].
QUESTION
I'm trying to build a Spotify web app now. I'd like to display an artist's albums when an user clicks the artist from its search result. When I try the code below, I get Request failed with status code 404.
SingerBox.js
...ANSWER
Answered 2020-May-31 at 05:44In SingerBox component you are trying to make get on http://localhost:4000/${id} there is not such API in your server.js file. that's why you encounter a 404 error which means not found
QUESTION
I am looking to get back the value "bearerToken" from the function "accesstokenAuth()". My issue is I'm not sure how to get that value out of a function even when I return/resolve it. Here is my code:
...ANSWER
Answered 2020-Aug-27 at 13:30The variable bearerToken
is out of scope since it is scoped within your function.
if you return resolve(bearerToken)
within your function then accessToken
should equal your bearerToken
.
Side note, you can rewrite your function like so.
I could be wrong but I don't think that you need the promise.
QUESTION
I just deployed a Spotify web app with Netlify. It works fine when it's running on my computer but it doesn't work on others. It shows Network Error, POST http://localhost:4000/search_result net::ERR_CONNECTION_REFUSED. I changed the url of the axios request to "/search_result" but it still didn't work. How should I fix it?
Here's my code.
Main.js
...ANSWER
Answered 2020-Jul-24 at 14:13It is likely that the server code isn't running as you expect it to.
Think about what commands you run to get that localhost
server running on your machine, compared to the build
command you provided o Netlify to build your site.
Netlify is primarily for hosting static sites, so will not automatically provide a backend server for you to use.
You can either host the server part of your app on something like Heroku (and then have to hard-code the URL of that server instance into your app), or you can use Netlify Functions to handle your basic post
request, which will let you use the relative URLs as in your question.
QUESTION
I'm making a web app that uses Spotify API now. I'd like to get a search keyword from client side and send its search result back to the client side. I'm making a post request with the search keyword to "http://localhost:4000/search_result" and send the result back to "http://localhost:4000/api" and then fetch the data. I get a 404 for the fetch call when I look into Network on the Chrome dev tool. And I'd also like to know if there's way to make use of the search keyword from the post request for a get request in server.js.
Main.js
...ANSWER
Answered 2020-May-21 at 02:34Your server side routes should be configured once, not on the fly. When you call app.post
and app.get
you are configuring a route and providing a callback that will be used every time a request comes in that matches that route. In your code, you create a post route, and then inside the handler you create a get route. Don't do that.
HTTP Servers are meant to be stateless. This means each request (post, get) know nothing about one another. If you want to share information between, you do it via a database (in-memory, redis, nosql, sql, etc...), where each route is using only the parameters passed to it.
For example, the POST route creates an id for the search results. The POST route returns this id. The GET route when called, should receive this same id and look up the results. Of course, this is only necessary for really long processes, typically job queues. For your specific case, you only need one route.
QUESTION
I'm trying to build a web app which uses Spotify API. I wanna use the input data that a user enters to call Spotify API on the server and send the result back to the front end. The problem is the page is redirected to 'http://localhost:4000/search_result' when I click the submit button. How do I prevent this?
main.js
...ANSWER
Answered 2020-May-18 at 06:16QUESTION
I think I am fundamentally misunderstanding how Promises work in Node.
I'm writing a very small Express app that I want to return a JSON of all of my Spotify playlists that contain a certain keyword. I am using spotify-web-api-node
from npm.
Spotify's API limits 50 playlists per request. I had (what I thought to be) a solution: simply increment the offset value until you no longer need to.
My functions looks like this (playlists
is declared above the route function) :
ANSWER
Answered 2019-Dec-03 at 20:45It's generally fine to use recursive promises, but there's a few things you're missing in your implementation. Each call to addPlaylistsToList()
creates a new promise, but only one call will create a new promise that actually resolves: the very last one. All the other created promises will be pending infinitely.
You can rewrite the function in a more typical recursive style, something like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spotify-web-api-node
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page