Hello,
Reading the documents on Okta Auth, I want to know if it was possible for Expo to allow authentication through the native mobile app instead of going through the Web browser way? Our project consists of an Email and Password field to login and I need it to authenticate using those methods without redirecting the user to another web page. Thank you!
import * as React from 'react';
import * as WebBrowser from 'expo-web-browser';
import { makeRedirectUri, useAuthRequest, useAutoDiscovery } from 'expo-auth-session';
import { Button, Platform } from 'react-native';
WebBrowser.maybeCompleteAuthSession();
const useProxy = Platform.select({ web: false, default: true })
export default function App() {
// Endpoint
const discovery = useAutoDiscovery('https://<OKTA_DOMAIN>.com/oauth2/default');
// Request
const [request, response, promptAsync] = useAuthRequest(
{
clientId: 'CLIENT_ID',
scopes: ['openid', 'profile'],
// For usage in managed apps using the proxy
redirectUri: makeRedirectUri({
// For usage in bare and standalone
native: 'com.okta.<OKTA_DOMAIN>:/callback',
useProxy,
}),
},
discovery
);
React.useEffect(() => {
if (response?.type === 'success') {
const { code } = response.params;
}
}, [response]);
return (
<Button
disabled={!request}
title="Login"
onPress={() => {
promptAsync({ useProxy });
}}
/>
);
}