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

Unable to use different Spotify Accounts on Android #230

Open
T1G3R192 opened this issue Jan 12, 2025 · 2 comments
Open

Unable to use different Spotify Accounts on Android #230

T1G3R192 opened this issue Jan 12, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@T1G3R192
Copy link

Is this a how to question?
No

Is this a native Spotify SDK issue?
No

Have you searched for existing issues?
Yes

Are you using a Free or Premium Spotify account?
Premium

Expected behavior
Set up a new android emulator device to test the sdk with a new account. Firstly, I was testing my code on a free account. Now, I want to test the behavior on my personal premium account. I expect everything to work as intended, after adding my new account to the spotify developer dashboard and rerun the code. I even used a new emulator to ensure the cache is not interfering.

Describe the bug
await SpotifySdk.connectToSpotifyRemote(); never finishes. There is no successful or failed connection.
Even on a new emulator it only works if I log into the previously used account.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Follow the pub.dev + Spotify Developer guide
  2. Ensure everything works as intended
  3. Create new android emulator, download Spotify App, log in with a different account
  4. Encounter bug: Previously working code, is not working anymore

Spotify_sdk Flutter package version
spotify_sdk: ^3.0.2

Target Platform, Version & Device

  • OS & Version: Windows, Android 14.0 x86_64 "UpsideDownCake"
  • Device: Medium Phone API 34, 6.4 1080x2400 420dpi

Development OS

  • OS: [e.g. Mac OS, Windows, Linux]

Additional context
Add any other information about the problem here.

@T1G3R192 T1G3R192 added the bug Something isn't working label Jan 12, 2025
@T1G3R192
Copy link
Author

The solution that worked for me is getting an access token, which was previoulsy not required, since I was not using the web api.

@brim-borium could you please double check, whether this is actually a bug or not? Maybe the access token is required regardless of using the web api or not, if so, please consider updating the docs on pub.dev.

Solution:

Step 1: call getAccessToken() inside your connectToSpotifyRemote() function
Step 2: set up the scope (more details here)
Step 3: pass the accessToken to connectToSpotifyRemote()
Step 4: restart the emulator and grant the necessary permissions

      final String accessToken = await SpotifySdk.getAccessToken(
        clientId: Secret.clientID,
        redirectUrl: Secret.redirectURL,
        scope:
            "app-remote-control,user-modify-playback-state,playlist-read-private",
      );

      bool result = await SpotifySdk.connectToSpotifyRemote(
        clientId: Secret.clientID,
        redirectUrl: Secret.redirectURL, 
        accessToken: accessToken,
      );

@Mohamed-Abdulla
Copy link

The solution that worked for me is getting an access token, which was previoulsy not required, since I was not using the web api.

@brim-borium could you please double check, whether this is actually a bug or not? Maybe the access token is required regardless of using the web api or not, if so, please consider updating the docs on pub.dev.

Solution:

Step 1: call getAccessToken() inside your connectToSpotifyRemote() function Step 2: set up the scope (more details here) Step 3: pass the accessToken to connectToSpotifyRemote() Step 4: restart the emulator and grant the necessary permissions

      final String accessToken = await SpotifySdk.getAccessToken(
        clientId: Secret.clientID,
        redirectUrl: Secret.redirectURL,
        scope:
            "app-remote-control,user-modify-playback-state,playlist-read-private",
      );

      bool result = await SpotifySdk.connectToSpotifyRemote(
        clientId: Secret.clientID,
        redirectUrl: Secret.redirectURL, 
        accessToken: accessToken,
      );

Hi, can u able to fetch accesstoken in ios ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants