How to implement webbrowser based authentication in react native expo? And the redirect_uri should be https

1k Views Asked by At

I'm using the expo-cli to build the project in react native, And also added this code in app.json

 "intentFilters": [
        {
          "action": "VIEW",
          "autoVerify": true,
          "data": [
            {
              "scheme": "https",
              "host": "app.your.xyz",
              "pathPrefix": "/cb"
            }
          ],
          "category": [
            "BROWSABLE",
            "DEFAULT"
          ]
        }
      ]

and also added linking on navigator in App.js

 const config =  {
    screens: {
      Home: "cb",
    },
  }
  const linking = {
    prefixes: ['https://app.your.xyz'],
    config
  };

<NavigationContainer linking={linking}>
    <SplashNavigator />
 </NavigationContainer>

this is my home screen

  function handledeepLink(event){
    let data = Linking.parse(event.url);
    const strData = Json.stringify(data);
    console.log(`data :: ${strData}`);
    ToastAndroid.show(`strData :: ${strData}`, ToastAndroid.SHORT);
  }

  useEffect (() => {
    Linking.addEventListener("url", handledeepLink);
    return(() => {
      console.log(`removing the listener`);
        Linking.removeEventListener("url")
    })
  }, [])

const autheticate = async () => {

        const redirectUri = 'https://app.your.xyz/cb'

const authurl = 'https://www.example.com' // example.com is some auth server url

const result = await WebBrowser.openAuthSessionAsync(authUrl, redirectUri)

}

when I to open this url it is not opening the app using below url it's not working https://app.your.xyz/cb

0

There are 0 best solutions below