expo: ValidationError: "returnUrl" must be a valid uri

Summary

As mentioned in this comment a new issue should be opened for using the projectNameForProxy property.

I get "returnUrl" must be a valid uri regardless of useProxy being true or false

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

iOS

SDK Version (managed workflow only)

45

Environment

  expo-env-info 1.0.4 environment info:
    System:
      OS: macOS 12.4
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.15.1 - /opt/homebrew/opt/node@16/bin/node
      npm: 8.11.0 - /opt/homebrew/opt/node@16/bin/npm
      Watchman: 2022.06.13.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    IDEs:
      Android Studio: 2021.1 AI-211.7628.21.2111.8193401
      Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
    npmGlobalPackages:
      eas-cli: 0.54.1
      expo-cli: 5.4.12

Reproducible demo

Same as original issue thread:

import * as AuthSession from "expo-auth-session";

const redirectUri = AuthSession.makeRedirectUri({
	native: "com.myapp://",
    useProxy:false
});

const authUrl = `https://supabaseproject.supabase.co/auth/v1/authorize?provider="google"&redirect_to=${redirectUri}`;

const signIn = async () => {
	const authRes = await AuthSession.startAsync({
		authUrl,
		returnUrl: redirectUri,
	});
};

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

same here… don’t know how to solve it

we deprecated the auth proxy (useProxy), which is what AuthSession.startAsync is meant for. I recommend using useAuthRequest if you’re interacting with an openid/oauth service, or otherwise, use WebBrowser.openAuthSessionAsync() instead, which has nothing to do with the deprecated auth proxy.

we’re working on cleaning this all up for sdk 49

I spoke too soon. The solutions above work for starting the login flow but Android fails to return back to the app after login. I dug a little further and it seems that the actual issue resides in the Linking.isExpoHost() function. On SDK 44, this function returns true for us under Expo Go but on SDK 45 it returns false. This seems to be related to moving Constants.manifest in SDK 44. Below is an updated patch we use with patch-package that works for us.

diff --git a/node_modules/expo-linking/build/Linking.js b/node_modules/expo-linking/build/Linking.js
index 6915cf7..be224e2 100644
--- a/node_modules/expo-linking/build/Linking.js
+++ b/node_modules/expo-linking/build/Linking.js
@@ -29,8 +29,12 @@ function getHostUri() {
 function isExpoHosted() {
     const hostUri = getHostUri();
     return !!(hostUri &&
-        (/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
-            Constants.manifest?.developer));
+        (
+            /^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
+            Constants.manifest?.developer ||
+            Constants.manifest2?.extra?.expoGo?.developer
+        )
+    );
 }
 function removeScheme(url) {
     return url.replace(/^[a-zA-Z0-9+.-]+:\/\//, '');
diff --git a/node_modules/expo-linking/src/Linking.ts b/node_modules/expo-linking/src/Linking.ts
index 56823aa..78dbbe2 100644
--- a/node_modules/expo-linking/src/Linking.ts
+++ b/node_modules/expo-linking/src/Linking.ts
@@ -37,10 +37,19 @@ function getHostUri(): string | null {
 
 function isExpoHosted(): boolean {
   const hostUri = getHostUri();
-  return !!(
-    hostUri &&
-    (/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
-      Constants.manifest?.developer)
+  return !!(hostUri &&
+      (
+          /^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
+          Constants.manifest?.developer ||
+          // `Constants.manifest?.developer` is no longer set under Expo 45 and
+          // seems to have moved under `manifest2.extra.expoGo`.
+          // See https://github.com/expo/expo/issues/18130
+          //
+          // Remove this patch when:
+          // ----------------------
+          // Login with Expo Go works without it.
+          Constants.manifest2?.extra?.expoGo?.developer
+      )
   );
 }

However, there’s a good chance that our upgrade path left us with some incorrect config somewhere. Here’s our app.json:

{
  "expo": {
    "owner": "apartment-snapshot",
    "name": "Apt Snap",
    "slug": "snapshot-ui",
    "version": "3.2.2",
    "orientation": "portrait",
    "icon": "./assets/icon-inverse.png",
    "scheme": "ourschemehere",
    "currentFullName": "...",
    "originalFullName": "...",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "cover",
      "backgroundColor": "#F44C7F"
    },
    "runtimeVersion": {
      "policy": "sdkVersion"
    },
    "updates": {
      "fallbackToCacheTimeout": 0,
      "url": "https://u.expo.dev/..."
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "bundleIdentifier": ...,
      "buildNumber": "3.2.2",
      "supportsTablet": true,
      "config": {
        "usesNonExemptEncryption": false
      }
    },
    "android": {
      "package": ...,
      "versionCode": 440030202,
      "adaptiveIcon": {
        "foregroundImage": "./assets/icon-inverse.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": ...
      }
    }
  }
}