Home IOS Development ios – Unhandled Exception: PlatformException with calling Spotify authorization in Flutter app

ios – Unhandled Exception: PlatformException with calling Spotify authorization in Flutter app

0
ios – Unhandled Exception: PlatformException with calling Spotify authorization in Flutter app

[ad_1]

I am attempting to make a easy Flutter software which has a consumer register to Spotify and mixture listening exercise, present stats, and many others.

I am having some hassle with the Spotify API. Each time I strive launch the Spotify authorization URL I am getting the next error message from Flutter.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(Error, Error whereas launching https://accounts.spotify.com/authorize/?response_type=code&client_id=6b12ed8ef79648e88e6646d7f16f5a50&scope=user-read-private&redirect_uri=http://localhost:8888//callback, null, null)

This is what my code for getting the URL appears like.

Future<void> login(BuildContext context) async {
    await dotenv.load();

    closing clientId = dotenv.env['SPOTIFY_CLIENT_ID'];
    closing scopes = dotenv.env['SPOTIFY_SCOPES'];
    closing redirectUri = dotenv.env['SPOTIFY_REDIRECT_URI'];
    closing url = Uri.parse('https://accounts.spotify.com/authorize/'
        '?response_type=code'
        '&client_id=$clientId'
        '&scope=$scopes'
        '&redirect_uri=$redirectUri');

    // Launch the constructed URL utilizing url_launcher
    await launchUrl(url);
  }

the place my surroundings variables are

SPOTIFY_CLIENT_ID=6b12ed8ef79648e88e6646d7f16f5a50
SPOTIFY_SECRET_ID=...
SPOTIFY_REDIRECT_URI=http://localhost:8888//callback
SPOTIFY_SCOPES=user-read-private

(facet notice: is it high-quality to share my shopper ID? I’ve eliminated my secret ID)

I’ve messed round with the redirect URI to no avail. And I’ve double-checked that my redirect URI is identical as my Spotify developer platform.

The eventual aim is to get a profitable login, get the consumer entry token, after which navigate out of the net authorization web page.

Thanks upfront for the assistance.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here