Trying to set up an authentication flow that runs in browser for a mobile app but the token url parameters in my app redirect(eg: exp://192.168.29.4:8081?token=<something>
) go missing .
A minimal reproducible example of my issue can be made by creating an app redirect with a token parameter on the backend as (using express to demonstrate):
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.redirect(302, 'exp://192.168.29.4:8081?token=something');
});
app.listen(3000, () => {});
and log the url parameters on the client side as
import * as Linking from "expo-linking";
...
const url = Linking.useURL();
if (url) {
console.log(url)
const { hostname, path, queryParams } = Linking.parse(url);
console.log(
`Linked to app with hostname: ${hostname}, path: ${path} and data: ${JSON.stringify(queryParams)}`);
}
If I open localhost:3000
on safari in the ios simulator, I am redirected to the app with the token parameter logged as expected. But If I use expo-linking or expo-web-browser as:
import * as Linking from "expo-linking";
...
Linking.openURL('http://127.0.0.1:3000')
or
import * as WebBrowser from "expo-web-browser";
...
await WebBrowser.openBrowserAsync('http://127.0.0.1:3000')
I am redirected to the app but the parameters are logged as empty.
How can I open the auth flow using Linking
or WebBrowser
and ensure that the app redirect contains the token parameters