I am using Expo in managed workflow and Expo Go as the debug app (on Android). SDK version is 46. I try to authenticate against an OpenID Connect service (provided by a Keycloak instance). I used the documentation and examples found on the Expo docs but wasn't able to get it running with some weird errors.
Here's my code:
WebBrowser.maybeCompleteAuthSession();
const useProxy = false;
const redirectUri = AuthSession.makeRedirectUri({
useProxy
});
export default function LoginIDPScreen({ navigation }: Props) {
const discovery = AuthSession.useAutoDiscovery('http://192.168.178.131:8080');
// Create and load an auth request
const [request, result, promptAsync] = AuthSession.useAuthRequest({
clientId: 'titan-mobile',
redirectUri,
scopes: ['openid', 'profile', 'email', 'offline_access'],
}, discovery);
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Button title="Login!" disabled={!request} onPress={() => promptAsync({ useProxy }) } />
{result && <Text>{JSON.stringify(result, null, 2)}</Text>}
</View>
);
}
Running this (hitting the "Login" button), it results in the following error:
WARN Possible Unhandled Promise Rejection (id: 0):
Error: Call to function 'ExpoWebBrowser.openBrowserAsync' has been rejected.
ā Caused by: No matching browser activity found
I tried to open a web browser manually using WebBrowser.openBrowserAsync('https://expo.dev') an that works fine, so I guess it's not actually about finding the browser activity.
When I read out the redirectUri it comes out as exp://192.168.178.130:19000, which I found weird as well, but given it can not even open the IDP for authentication, I think this is not the issue.
I intentionally switched off the proxy, afaik the proxy does not work with development envs. Enabling the proxy results in another error:
ERROR Error: Cannot use the AuthSession proxy because the project full name is not defined. Prefer AuthRequest (with the useProxy option set to false) in combination with an Expo Development Client build of your application. To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.
Adding projectNameForProxy to the arguments for promptAsync() does not work and looking at the documentation for AuthRequest, it strongly recommends not using it and using AuthSession instead..
Any ideas?