How to use the react-native-app-auth.refresh function in react-native-app-auth

To help you get started, we’ve selected a few react-native-app-auth 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 zzorba / ArkhamCards / lib / auth.ts View on Github external
.then(creds => {
      if (creds) {
        const data = JSON.parse(creds.password);
        const nowSeconds = (new Date()).getTime() / 1000;
        const expiration = new Date(data.accessTokenExpirationDate).getTime() / 1000;
        if (data.refreshToken && expiration < nowSeconds) {
          return refresh(config, { refreshToken: data.refreshToken })
            .then(
              saveAuthResponse,
              () => {
                // Null token will produce an error where it is used.
                return null;
              });
        }
        return data.accessToken;
      }
      return null;
    });
}
github mozilla / notes / native / app / vendor / fxa-utils.js View on Github external
.then((resp) => {
      // if 200 then token is valid, no need to review
      if (resp.status !== 200) {
        // if error attempt to renew access token
        return refresh(refreshConfig, {
          refreshToken: refreshToken
        });
      }
    }, () => {
      throw new Error('Failed to verify token');
github oktadeveloper / okta-react-native-app-auth-example / App.js View on Github external
refresh = async () => {
    try {
      const authState = await refresh(config, {
        refreshToken: this.state.refreshToken
      });

      this.animateState({
        accessToken: authState.accessToken || this.state.accessToken,
        accessTokenExpirationDate:
          authState.accessTokenExpirationDate || this.state.accessTokenExpirationDate,
        refreshToken: authState.refreshToken || this.state.refreshToken
      });
    } catch (error) {
      Alert.alert('Failed to refresh token', error.message);
    }
  };
github FormidableLabs / react-native-app-auth / Example / AndroidExample / App.js View on Github external
refresh = async () => {
    try {
      const authState = await refresh(config, {
        refreshToken: this.state.refreshToken,
      });

      this.animateState({
        accessToken: authState.accessToken || this.state.accessToken,
        accessTokenExpirationDate:
          authState.accessTokenExpirationDate || this.state.accessTokenExpirationDate,
        refreshToken: authState.refreshToken || this.state.refreshToken,
      });
    } catch (error) {
      Alert.alert('Failed to refresh token', error.message);
    }
  };
github FormidableLabs / react-native-app-auth / Example / iOSCarthageExample / App.js View on Github external
refresh = async () => {
    try {
      const authState = await refresh(config, {
        refreshToken: this.state.refreshToken
      });

      this.animateState({
        accessToken: authState.accessToken || this.state.accessToken,
        accessTokenExpirationDate:
          authState.accessTokenExpirationDate || this.state.accessTokenExpirationDate,
        refreshToken: authState.refreshToken || this.state.refreshToken
      });
    } catch (error) {
      Alert.alert('Failed to refresh token', error.message);
    }
  };

react-native-app-auth

React Native bridge for AppAuth for supporting any OAuth 2 provider

MIT
Latest version published 3 months ago

Package Health Score

93 / 100
Full package analysis