0

I am trying to authenticate a flutter application against Spotify. For this, I use the flutter_web_auth package. I have a button to authenticate against Spotify. Once user clicks the button, the following function operates:

onPressed: () async {
  final spotifyAuthURL = Uri.https(
    'accounts.spotify.com',
    '/authorize',
    {
      'response_type': 'code',
      'client_id': dotenv.get('SPOTIFY_CLIENT_ID'),
      'redirect_uri':
          'https://vinyl_app_spotify.com/callback',
      'scope': 'user-read-private user-read-email',
    },
  );

  final result = await FlutterWebAuth.authenticate(
    url: spotifyAuthURL.toString(),
    callbackUrlScheme:
        'https://vinyl_app_spotify.com/callback',
  );
},

I've also added the following activiy to the AndroidManifest.xml file as I should have done according to the flutter_web_auth package:

<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
    <intent-filter android:label="flutter_web_auth">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https://vinyl_app_spotify.com/callback" />
    </intent-filter>
</activity>

So after I click my application button, I do get access to Spotify, then the redirect url kicks in, but I just see this: enter image description here

So my android emulator could not capture the callback url.

What is my mistake? Any advice..

4
  • Are you sure vinyl_app_spotify.com is the correct url? Commented Sep 16, 2021 at 10:36
  • @MikkelT What do you mean by correct url? This is the arbitrary custom url I chose Commented Sep 16, 2021 at 10:50
  • Yeah but you shouldn't use an arbitrary URL, you should use a URL that returns a callback action. Edit: ah sorry, maybe I misunderstood. Maybe this will help? stackoverflow.com/questions/2665796/… Commented Sep 16, 2021 at 10:52
  • @MikkelT Spotify allows only http/s schemas for redirect url Commented Sep 16, 2021 at 11:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.