Expo Go and Okta 400 Bad Request

Hi,

I’m struggling with Okta integration.

This is my login screen:

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 });

function LoginScreen({ navigation, route }) {
  // Endpoint
  const discovery = useAutoDiscovery('https://dev-48613121.okta.com/oauth2/default');
  // Request
  const [request, response, promptAsync] = useAuthRequest(
    {
      clientId: '0oa7rrzvnh0utfn0f5d7',
      scopes: ['openid', 'profile'],
      // For usage in managed apps using the proxy
      redirectUri: makeRedirectUri({
        // For usage in bare and standalone
        //native: 'com.okta.dev-48613121:/callback',
        //native: 'exp://192.168.1.146:19000/--/redirect',
        native: 'exp://192.168.1.146:19000',
        useProxy,
      }),
    },
    discovery
  );

  React.useEffect(() => {
    if (response?.type === 'success') {
      const { code } = response.params;
    }
  }, [response]);

  return (
    <Button
      disabled={!request}
      title="Login"
      onPress={() => {
        promptAsync({ useProxy });
      }}
    />
  );
}

export default LoginScreen

I’m using the Expo Go app, which is running on exp://192.168.1.146:19000
I configured Okta to redirect to exp://192.168.1.146:19000, where I allowed for: Allow wildcard * in login URI redirect.

Okta issue:

Okta 400 Bad Request
Your request resulted in an error. The 'redirect_uri' parameter must be a Login redirect URI in the client app settings: https://dev-48613121-admin.okta.com/admin/app/oidc_client/instance/0oa7rrzvnh0utfn0f5d7#tab-general

Please advise me on how to configure a callback.
I appreciate any help you can provide.

Hi @xkbit,

As per the docs here it seems Okta should provide a redirect UI and you cannot define a custom one. I haven’t tried it myself but I am making sure that you are aware of this.