Auth Session doesn't redirect back


#1

Hi I am trying to implement trade.it 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({
      authUrl:
        `${oAuthURL}` +
        `&redirect_uri=${encodeURIComponent(redirectUrl)}`,
    });
    this.setState({ oAuthResponse: result });
  };

Trade.it 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:

https://auth.expo.io/@emmaai/emmaai

I am using latest version:

    "expo": "^32.0.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",

#2

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://192.168.0.11:19000   in dev mode
    const redirectUrl2 = Constants.linkingUrl; // exp://192.168.0.11:19000/ in dev mode


#3

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 “Expo.io 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:

https://docs.expo.io/versions/latest/workflow/configuration/


#5

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.


#6

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

Blockquote
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.


closed #7

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