Flutter spotify_sdk: 2.3.0 connection problem - cant get token

Viewed 50

I'm kinda new to Flutter + Dart, for my second app I want to work on a spotify app for android. I found the spotify sdk on pub dev and did my best to work with the docs from spotify and from pub dev but I dont get the token :(

First of all: I have a debug.keystore in my ../android/app/ and put the debug sha1 fingerprint on spotify console with a callback url. I did everything from the spotify_sdk readme.

I tried it with different callback methods like: redirectUrl: http://bundle_id/callback, redirectUrl: bundle_id://callback, redirectUrl: http://bundleid/auth, and everything with the client_id and client_secret (because the docs are not clear for me what I should use).

It would be great if you guys could help out. I'm alone and dont have dev friends to ask D:

This is my code

import 'package:flutter/material.dart';
import 'package:spotify_sdk/spotify_sdk.dart';

void main() {
  runApp(const MaterialApp(
    home: HomePage(),
  ));
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('spotify auth test'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Align(
            alignment: Alignment.center,
            child: ElevatedButton(
              onPressed: getAccessToken,
              child: const Text('GIMMI TOKEN PLS'),
            ),
          ),
        ],
      ),
    );
  }

  Future<String> getAccessToken() async {
    try {
      var authenticationToken = await SpotifySdk.getAccessToken(
          clientId: 'client_id',
          redirectUrl: 'redirectUrl',
          scope: 'app-remote-control, '
              'user-modify-playback-state, '
              'playlist-read-private, '
              'playlist-modify-public,user-read-currently-playing');
      print('Got a token: $authenticationToken');
      return authenticationToken;
    } catch (e) {
      print('$e.code, message $e.message');
      return Future.error('$e.code: $e.message');
    } /*catch (e) {
      print('not implemented');
      return Future.error('not implemented');
    }*/
  }
}

And this is my error log message:

I/flutter ( 7987): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 7987): │ #0   SpotifySdk._logException (package:spotify_sdk/spotify_sdk.dart:633:15)
package:spotify_sdk/spotify_sdk.dart:633
I/flutter ( 7987): │ #1   SpotifySdk.getAccessToken (package:spotify_sdk/spotify_sdk.dart:128:7)
package:spotify_sdk/spotify_sdk.dart:128
I/flutter ( 7987): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 7987): │ ⛔ getAccessToken failed with: Authentication went wrong
I/flutter ( 7987): │ ⛔ AUTHENTICATION_SERVICE_UNKNOWN_ERROR
I/flutter ( 7987): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 7987): PlatformException(authenticationTokenError, Authentication went wrong, AUTHENTICATION_SERVICE_UNKNOWN_ERROR, null).code, message PlatformException(authenticationTokenError, Authentication went wrong, AUTHENTICATION_SERVICE_UNKNOWN_ERROR, null).message
E/flutter ( 7987): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(authenticationTokenError, Authentication went wrong, AUTHENTICATION_SERVICE_UNKNOWN_ERROR, null).code: PlatformException(authenticationTokenError, Authentication went wrong, AUTHENTICATION_SERVICE_UNKNOWN_ERROR, null).message
E/flutter ( 7987):

0 Answers
Related