How to use the react-native-config.API_AUTH function in react-native-config

To help you get started, we’ve selected a few react-native-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forest-watcher / forest-watcher / app / redux-modules / user.js View on Github external
return async (dispatch: Dispatch) => {
    try {
      dispatch({ type: SET_LOGIN_LOADING, payload: true });
      const user = await authorize(oAuth.google);
      try {
        const response = await fetch(`${Config.API_AUTH}/auth/google/token?access_token=${user.accessToken}`);
        dispatch({ type: SET_LOGIN_LOADING, payload: false });
        if (!response.ok) throw new Error(response.status);
        const data = await response.json();
        dispatch({
          type: SET_LOGIN_AUTH,
          payload: {
            socialNetwork: 'google',
            loggedIn: true,
            token: data.token,
            oAuthToken: user.accessToken
          }
        });
      } catch (e) {
        console.error(e);
        dispatch({ type: SET_LOGIN_LOADING, payload: false });
        dispatch(logout('google'));
github forest-watcher / forest-watcher / app / components / login / index.js View on Github external
onLoadEnd = () => {
    const parsedUrl = parseUrl(this.state.webViewCurrenUrl, true);
    if (
      parsedUrl.origin == Config.API_AUTH &&
      parsedUrl.pathname == Config.API_AUTH_CALLBACK_PATH &&
      parsedUrl.query?.token
    ) {
      this.props.setLoginAuth({
        token: parsedUrl.query.token,
        socialNetwork: this.state.socialNetwork,
        loggedIn: true
      });
    }
  };
github forest-watcher / forest-watcher / app / components / login / index.js View on Github external
webViewProvider = (socialNetwork: string) => {
    const callbackUrl = `${Config.API_AUTH}${Config.API_AUTH_CALLBACK_PATH}`;
    const url = `${Config.API_AUTH}/auth/${socialNetwork}?token=true&callbackUrl=${callbackUrl}`;
    this.setState({
      socialNetwork,
      webviewVisible: true,
      webViewUrl: url
    });
  };