spotify-web-api-node icon indicating copy to clipboard operation
spotify-web-api-node copied to clipboard

Uncaught TypeError: spotifyApi.authorizationCodeGrant is not a function

Open reidpd opened this issue 8 years ago • 8 comments

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!

reidpd avatar Sep 13 '17 23:09 reidpd

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

FerRubioMorales avatar Sep 25 '17 13:09 FerRubioMorales

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

brodin avatar Sep 29 '17 14:09 brodin

hi, @reidpd Did you solve the problem?

yemecen avatar Nov 16 '17 12:11 yemecen

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

paddy-flynn avatar Apr 28 '18 10:04 paddy-flynn

@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.

JMPerez avatar Apr 28 '18 11:04 JMPerez

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

paddy-flynn avatar Apr 28 '18 15:04 paddy-flynn

I’m opening the issue again

JMPerez avatar Apr 28 '18 17:04 JMPerez

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?

slatzz avatar Oct 18 '20 05:10 slatzz