thelinmichael / spotify-web-api-node

A Node.js wrapper for Spotify's Web API.
http://thelinmichael.github.io/spotify-web-api-node/
MIT License
3.1k stars 499 forks source link

Uncaught TypeError: spotifyApi.authorizationCodeGrant is not a function #157

Open reidpd opened 7 years ago

reidpd commented 7 years ago

Expected: authorizationCodeGrant should be a function available for access using the library.

Actual: spotifyApiInstanceWithCredentials.authorizationCodeGrant is not a function.

When the instance is logged to the browser console, 'authorizationCodeGrant' does not appear as an available function for access.

This code was recently changed in an accepted PR.

Unable to get past this oauth business, help!

FerRubioMorales commented 6 years ago

Some work in progress? I'm getting the same error

brodin commented 6 years ago

You can't run authorizationCodeGrant in the browser since this is part of the "server code" (https://github.com/thelinmichael/spotify-web-api-node/blob/master/src/server.js) and you can find where this magi happens here https://github.com/thelinmichael/spotify-web-api-node/blob/master/package.json#L50

yemecen commented 6 years ago

hi, @reidpd Did you solve the problem?

paddy-flynn commented 6 years ago

Hi, I'm getting the same issue. What's the resolution?

JMPerez commented 6 years ago

@Flynnp25 The issue means you are trying to run the code from the browser, and not the nodejs server. The call needs to be made from the server, since it includes the client secret that shouldn't be exposed. You can read more about the authorization flow in the README and Spotify's developer site](https://beta.developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow).

Since the token exchange involves sending your secret key, perform this on a secure location, like a backend service, and not from a client such as a browser or from a mobile app.

paddy-flynn commented 6 years ago

I get this error on the server side. I've a node backend and and angular front end

JMPerez commented 6 years ago

I’m opening the issue again

slatzz commented 3 years ago

I am build a React app and am able to successfully get a token from the server side, but how do I access that token for my API call on the client side?