Return "Authentication" property useAuthRequest() is coming "null" | expo-auth-Session

Asked

Viewed 31 times

0

I have a problem with returning the accessToken and the idToken after authentication with lib expo-auth-Session, implemented for connection with the Identity Server. It opens the login page and successfully returns to the application. I am following the example of the expo documentation, however the property authentication is returning null.

WebBrowser.maybeCompleteAuthSession();

const useProxy = true;

const redirectUri = AuthSession.makeRedirectUri({
  native: CALLBACK_URL,
  useProxy,
});

const config = {
  clientId: CLIENT_ID,
  scopes: ['openid', 'profile', 'email', 'offline_access'],
};

const AuthButton: React.FC = () => {
  const [loading, setLoading] = useState(false);
  const discovery = AuthSession.useAutoDiscovery(HOST_URL);

  // Create and load an auth request
  const [request, response, promptAsync] = AuthSession.useAuthRequest(
    {
      ...config,
      redirectUri,
    },
    discovery
  );

  async function openAuth() {
    setLoading(true);
    const responseToken = await promptAsync({ useProxy });
    Alert.alert('Authentication', JSON.stringify(responseToken.authentication));
    setLoading(false);
  }

  return (
    <>
      <Button type="dark" disabled={loading} onPress={openAuth}>
        {loading ? 'Carregando...' : 'Acessar'}
      </Button>
    </>
  );
};

Could someone give me a hand?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.