authorize promise never resolves/rejects
See original GitHub issueIssue
I have a simple app where I want to use Spotify
as a way to register/log in. I followed the setup steps and implemented the authorization logic like this:
const openSpotify = async () => {
const spotifyAuthConfig = {
clientId: SPOTIFY_APP_CLIENT_ID,
redirectUrl: 'org.example.app://callback',
scopes: ['user-read-email'],
serviceConfiguration: {
authorizationEndpoint: 'https://accounts.spotify.com/authorize',
tokenEndpoint: 'https://accounts.spotify.com/api/token',
},
};
try {
const result = await authorize(spotifyAuthConfig); // this promise hangs forever
console.log(JSON.stringify(result)); // this never runs
return result;
} catch (error) {
console.error(JSON.stringify(error)); // this never runs
}
};
return (
<View style={styles.container}>
<Button title={t('LOGIN_BUTTON')} onPress={openSpotify} />
</View>
);
When I click on my login button, the message “ExampleApp Wants to Use spotify.com to Sign In” pops, and then I can sign in with my spotify account, press allow and the window dissapears but nothing happens. The authorize()
promise stays pending even though the process went through. Any ideas what can I be doing wrong?
Environment
- Your Identity Provider:
Spotify OAuth
- Platform that you’re experiencing the issue on:
iOS
- Are you using Expo?
No
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Detecting a promise that will never resolve/ reject
I ran into an interesting JavaScript problem today: How to detect a promise that will never resolve/ reject?
Read more >Promises does not wait resolve or reject - javascript - ReactJs
resolve (authorization), you can just return authorization . The .then creates a new promise for you. if (moment(now).isAfter(expiration)) ...
Read more >Promise Error Handling - JavaScript Tutorial
In this tutorial, you will learn about promise error handling that shows you how to handle error in promises.
Read more >Detecting a promise that will never resolve/ reject
I ran into an interesting JavaScript problem today: How to detect a promise that will never resolve/ reject?
Read more >Functional Node.js: Working with Promises | during the drive
It's hard to read, harder to debug, and chances are you aren't exiting (resolving/rejecting) the promise properly. Using defer, Ever. I don't ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had a similar issue and discovered it was due to a missing trailing slash on the redirect url.
Change your
redirectUrl
fromorg.example.app://callback
toorg.example.app://callback/
See https://github.com/FormidableLabs/react-native-app-auth/issues/380#issuecomment-581517451
Thanks @badsyntax . You save my day.