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.

[expo-auth-session] redirect URI doesn't work on iOS (spotify api)

See original GitHub issue

🐛 Bug Report

Summary of Issue

I’m using expo-auth-session to connect to spotify, this works in the expo app but when I release to testflight, the redirect uri is not valid (illegal uri).

Reproducible Demo

I followed the spotify demo on the expo documentation site. The app names ‘com.company.app’ etc are correctly added in the developer panel of spotify.

My auth code looks like this:

const [request, response, promptAsync] = useAuthRequest(
    {
      clientId: "{id}",
      scopes: [
        "user-read-email",
        "user-read-playback-state",
        "user-modify-playback-state",
        "playlist-modify-public",
      ],
      // In order to follow the "Authorization Code Flow" to fetch token after authorizationEndpoint
      // this must be set to false
      usePKCE: false,
      // For usage in managed apps using the proxy
      redirectUri: makeRedirectUri({
        // For usage in bare and standalone
        native: Platform.select({
          android: `be.{company}.{app}//redirect`,
          ios: `be.{company}.{app}//redirect`,
        }),
      }),
    },
    discovery
  );

Steps to Reproduce

use the code above, connect to spotify.

Expected Behavior vs Actual Behavior

In the expo app it will work, however, once you deploy to testflight or wherever. It will crash and return ‘illegal url’

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Pixelatexcommented, Oct 30, 2020

so probably my issue was that I used com.domain.name//redirect instead of name//redirect. Should work now

2reactions
SleeplessBytecommented, Oct 2, 2020

We have this working in production. Only real difference is that we use:

const SCHEME = Constants.manifest.scheme;
const useProxy = Constants.appOwnership === 'expo' && Platform.OS !== 'web';

...

     redirectUri: makeRedirectUri({
        // For usage in bare and standalone
        native: `${SCHEME}://redirect`,
        useProxy,
      }),
Read more comments on GitHub >

github_iconTop Results From Across the Web

AuthSession - Expo Documentation
Initiation: the user presses a sign in button; Open web browser: the app ... If the URL that the auth service is redirecting...
Read more >
Couldn't get back in my app once i'm login in with spotify
Run expo start:web --https to run with https, auth won't work ... If the redirect URIs are not setup then Spotify won't know...
Read more >
Trouble With Expo React-Native Spotify Authentication
Fix the Facebook login error “URL blocked: This redirect failed because the redirect URI is In this article, we show you how to...
Read more >
Understanding Spotify OAuth for React Native/Expo Apps
Spotify's API is incredible, but it can be confusing to figure out ... If you're not using Expo, just choose a Redirect URI...
Read more >
Spotify Authentication with React Native | by Kevin Tomas
When I first started this project, I faced the problem that there were not ... the authentication process with Spotify, ReactNative and expo-auth-session....
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