Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spotify-web-api-ts-sdk AuthorizationCodeWithPKCEStrategy broken on React Native #98

Open
murray-lang opened this issue Dec 31, 2023 · 1 comment

Comments

@murray-lang
Copy link

murray-lang commented Dec 31, 2023

I'm new to both Spotify development and React Native development, so please forgive me if I betray too much lack of understanding.

  • I'm building a custom Spotify player using React Native, currently targeting Android.
  • In my app, I'm using the @spotify/web-api-ts-sdk npm package, rather than building the web-api-ts-sdk sources into my bungles.
  • When the app runs in the Android emulator, I get the exception "Cannot read property 'search' of undefined" in the function redirectOrVerifyToken(), particularly the line:
    const hashParams = new URLSearchParams(window.location.search);
    ...but I believe it's expected that location is undefined in the window object of a React Native application.

So it looks to me that this code was not written with React Native in mind, and will never work.
Is this code wrong or am I wrong?
Is it my error to expect AuthorizationCodeWithPKCEStrategy to be relevant to React Native?

@murray-lang murray-lang changed the title spotify-web-api-ts-sdk AuthorizationCodeWithPKCEStrategy() broken on React Native spotify-web-api-ts-sdk AuthorizationCodeWithPKCEStrategy broken on React Native Dec 31, 2023
@murray-lang
Copy link
Author

It looks like I'll need to write an implementation of IAuthStrategy based on an expo AuthSession.
I'm trying this based on:
https://medium.com/@zachrach/spotify-web-api-authorization-with-react-native-expo-6ee1a290b2b0
...though I'm not happy with the handling of the client secret. I'll worry about that later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant