Auth Session doesn't redirect back

Hi I am trying to implement auth.

Once I open web browser it never redirects back to my app.

  openOauthPopupAsync = async (oAuthURL) => {
    const redirectUrl = AuthSession.getRedirectUrl();
    const result = await AuthSession.startAsync({
        `${oAuthURL}` +
    this.setState({ oAuthResponse: result });
  }; oAuth popup opens, I enter username and password, but popup doesn’t close.

I can cancel it and get back to the app with response:

{type: "cancel"}

I aslo set scheme in app.json

    "scheme": "emmaai",

if I log redirectUri, I will get:

I am using latest version:

    "expo": "^32.0.0",
    "react": "16.5.0",
    "react-native": "",

I also tryed using webBrowser:

  openOauthPopupAsync = async (oAuthURL) => {
    const redirectUrl = Linking.makeUrl();
    const redirectUrl2 = Constants.linkingUrl;
    const result = await WebBrowser.openAuthSessionAsync(`${oAuthURL}`, redirectUrl );
    this.setState({ result });

The same thing happens, I tried using both redirect urls:

    const redirectUrl = Linking.makeUrl(); // exp://   in dev mode
    const redirectUrl2 = Constants.linkingUrl; // exp:// in dev mode

That module is pretty nasty and I would discourage you from using it. I was able to get it to work but at best, it will show a popup asking “ wants permission to log in” or something like that. I consider that to be atrocious user experience and completely unacceptable from a usability perspective.

I would encourage you to research and find out if there is an api endpoint that can give you an auth token… It looks like they do have support for an entirely programmatic flow:

Hi, thanks for response.

I tried using webBrowser, but it seems whatever i use, I cannot redirect back.

I don’t really mind Expo permissions popup.

Do you maybe have any example that works ?

I just need example of the redirecting back to the app, but there seems to be lot of issues with that part.

I got response from trade it support team. There is no way for me to use API directly.
Full respopnse:

Thank you for your query to TradeIt. As it relates to the account linking process, we only work with brokers’ APIs that support oAuth. Thus, the end user will also be required to link their brokerage account with their own log in credentials. We do not capture the end user’s log in credentials nor do we capture any personal identifiable information. As such, the oAuth screen is required to be presented to the end user to initial link their account. Once the account is linked, a refresh token will be issued, allowing the user to access their account for portfolio refreshes, etc.

Hope this helps as well as provides you with the rationale for the oAuth screen presentation.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.