Closed evaqum closed 2 years ago
Hmm, I think I've either done something wrong while trying to get your branch up-to-date (so I could merge it), or Github doesn't behave well with merge conflicts...
Could you maybe reset your branch to your own commit and then try to rebase/merge with this master yourself?
Thanks and sorry for reacting so late!!
I think I did it? Hope I didn't mess up
upd: okay I actually messed up
Now everything should be fine (I really hope so!)
Right now the only way to instantiate SpotifyApi class with credentials is like this:
But with wrong credentials you get AuthorizationException, which you can't catch with any obvious way (and probably can't catch without modifying the library itself at all)
That is because
_getOauth2Client
method never gets awaited and is instantly used in class. https://github.com/rinukkusu/spotify-dart/blob/7af8323ebe3831fac1ac8beb72aa5c991728f827/lib/src/spotify_base.dart#L54-L56However, this PR allows instantiating SpotifyApi asynchronously with static method
asyncFromCredentials
, meaning that exceptions can be handled in<Future>.catchError
or a try/catch block.I also added export from oauth2 package exposing
AuthorizationException
andExpirationException
so these can be handledMight resolve #73