expo: Cannot use AuthSession proxy because the project ID is not defined.

Summary

I am trying to use Expo App Auth in a Bare Workflow. I’ve succesfully installed unimodules and the following packages: expo-constants, expo-linking, expo-auth-session.

For the login process, I am using supabase. Given below is the code.

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

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

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

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

However, this results in an unhandled promise rejection with the error

Error: Cannot use AuthSession proxy because the project ID is not defined. Please ensure you have the latest version of expo-constants installed and rebuild your native app. You can verify that originalFullName is defined by running `expo config --type public` and inspecting the output.

I ran expo config --type public and it successfully emits the originalFullName and currentName. I also tried setting it explicitly in app.json and app.config.js. Even after rebuilds, the issue persists.

I tried to check if originalFullName exists in the Constants.manifest and it doesnt; The manifest is null in bare workflow.

import * as Constants from "expo-constants";

console.log(Constants.default.null)

So I set it explicitly before calling AuthSession like this

if (Constants.default.manifest === null) {
	Constants.default.manifest = {};
	Constants.default.manifest.currentFullName = "@nikketan/myapp";
	Constants.default.manifest.originalFullName = "@nikketan/myapp";
}

But this too doesnt work and the error persists.

Is there anything I am missing ?

Thanks

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

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

No response

Environment

Expo CLI 4.8.1 environment info: System: OS: Linux 5.12 Fedora 34 (Workstation Edition) 34 (Workstation Edition) Shell: 3.3.1 - /usr/bin/fish Binaries: Node: 15.11.0 - /usr/bin/node Yarn: 1.22.4 - ~/.npm-global/bin/yarn npm: 7.20.0 - ~/.npm-global/bin/npm Watchman: 20210425.225316.0 - /usr/local/bin/watchman npmPackages: react: 17.0.2 => 17.0.2 react-native: 0.64.2 => 0.64.2 Expo Workflow: bare

Reproducible demo or steps to reproduce from a blank project

  • Create a bare workflow using Create React Native app,

  • App Expo Unimodules, configure.

  • Add Expo constants, app auth , expo-random and web browser.

  • Use the code given above in a login page to login.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I found a solution, but I’m not sure why this is related. However, we were using EAS Update as generated by the eas update:configure command as outlined in this documentation.

We added the fields that looked something like this:

{
  "updates": {
    "url": "<URL TO UPDATE ENDPOINT>"
  },
  "runtimeVersion": {
    "policy": "sdkVersion"
  }
}

Here’s the kicker. After this change, the renderer would error with the error outlined in this issue. Adding the fields from expo config --type public fixed this error, but caused another issue:

When prompting for the auth, directing to auth.expo.io/... the endpoint would fail with the following error:

ValidationError: "returnUrl" must be a valid uri

Undoing the above changes, removing runtimeVersion and falling back to the default updates config fixed the issue:

"updates": {
  "fallbackToCacheTimeout": 0
},

This section may be a clue, but still not sure why it would not just get the manifest correctly.

I don’t know if this is a feature or a bug, but the error messages and documentation isn’t clear on what may not work when using EAS Update.

Edit:

Another clue is this section from the EAS Update Migration documentation. Specifically this line:

  • Remove any code that references Constants.manifest. That will now always return null.

This would make any code that relies on the manifest not work at all, which is what happens in expo-auth-session package.

The PR (#17327) adds an argument to the function so that you can specify originalFullName without the hack.

Overall, we suggest using the non-proxied set of auth tools this library provides in combination with a development client build, but for now we’ll continue to support EAS update manifests in combination with the library with this new argument. Sorry for the thrash.

I’ll close this issue once a new version of the library is released.

Hi, thank you for adding the parameters, now it works!

May you describe the solution without the prox + development client a little bit more? I want to migrate but not sure how to do it exactly

Thank you for taking to the time to look into this! I gave this a try and the old error regarding the project id is gone, but now I get:

ValidationError: "returnUrl" must be a valid uri

This was also refrenced in one of the comments above. Should I open a new issue for this?