question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

authorize promise never resolves/rejects

See original GitHub issue

Issue

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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
badsyntaxcommented, Mar 10, 2021

Had a similar issue and discovered it was due to a missing trailing slash on the redirect url.

Change your redirectUrl from org.example.app://callback to org.example.app://callback/

See https://github.com/FormidableLabs/react-native-app-auth/issues/380#issuecomment-581517451

1reaction
mashish584commented, Mar 17, 2021

Thanks @badsyntax . You save my day.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found