brim-borium / spotify_sdk

Flutter Package to connect the spotify sdk
https://pub.dev/packages/spotify_sdk
Apache License 2.0
152 stars 82 forks source link

getAccessToken #172

Closed Justus-M closed 2 years ago

Justus-M commented 2 years ago

!! Attention !! FILL IN ALL SECTIONS OF THIS TEMPLATE OR YOUR ISSUE WILL BE CLOSED WITHOUT INVESTIGATION This is a flutter package that wraps the native iOS and Android Spotify "remote" SDKs as well as the Spotify Web Playback SDK for web. Since it wraps the native SDKs it has the same features and limitations. Please use the search functionality in the native SDK repos to find corresponding issues before opening an issue here. If your issue is deriving from the native SDKs you should open an issue there and not in this repo.

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

Are you aware of the limitations of Free Spotify accounts? Yes

Expected behavior I expect getAccessToken to open spotify, ask me to authenticate, and return a string

Describe the bug Spotify opens, the authentication window brielfy opens and then closes, and shows a check mark.

When I use the web address (which works for web based authentication) as the redirectUrl, it opens the url with the spotify version number and an error "invalid_scope"

When I use the app url scheme as the redirectUrl, spotify opens my flutter app and I get the following error output in flutter: flutter:

\^[[38;5;196m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;196m│ #0   SpotifySdk._logException (package:spotify_sdk/spotify_sdk.dart:633:15)<…>
package:spotify_sdk/spotify_sdk.dart:633
flutter: \^[[38;5;196m│ #1   SpotifySdk.getAccessToken (package:spotify_sdk/spotify_sdk.dart:128:7)<…>
package:spotify_sdk/spotify_sdk.dart:128
flutter: \^[[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;196m│ ⛔ getAccessToken failed with: <…>
flutter: \^[[38;5;196m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: PlatformException(authenticationTokenError, null, null, null)
#0      StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:607
#1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:167
<asynchronous suspension>
#2      SpotifySdk.getAccessToken
package:spotify_sdk/spotify_sdk.dart:119
<asynchronous suspension>
#3      SuggestionService.loadSpotify
package:Planou/…/services/suggestion_service.dart:206
<asynchronous suspension>
8.11.0 - [Firebase/Firestore][I-FST000001] WatchStream (121f7ccc8) Stream error: 'Unavailable: Network connectivity changed'
8.11.0 - [Firebase/Firestore][I-FST000001] WriteStream (121f8c398) Stream error: 'Unavailable: Network connectivity changed'
8.11.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
    "spotify_version" = "8.7.40.1558";
}

Steps to Reproduce Steps to reproduce the behavior:

spot2.SpotifySdk.getAccessToken( clientId: 'entered my client id here', redirectUrl: 'entered my redirect url here', scope: "user-library-read");

Screenshots If applicable, add screenshots to help explain your problem.

Spotify_sdk Flutter package version Check you pubspeck.lock file to verify the exact version [e.g 2.1, commit ID] 2.3.0

Target Platform, Version & Device

Development OS

Additional context I only have two scopes enabled, user-library-read and the top artists one, but I am only using user-library-read here and it is definitely enabled and works when I auth via web. I've been trying to make this work all day, some things I tried:

  1. creating a new URL scheme and registering it on the spotify dashboard
  2. Going through the "Setup the iOS SDK" instructions of Spotify iOS SDK Quick Start as instructed, several times.
Justus-M commented 2 years ago

https://community.spotify.com/t5/Spotify-for-Developers/Getting-error-invalid-scope-when-we-authenticate-with-the/m-p/5393177