How to use the react-native-config.OAUTH_SITE 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 zzorba / ArkhamCards / components / decks / actions.ts View on Github external
return (dispatch) => {
    const uri = `${Config.OAUTH_SITE}api/public/${useDeckEndpoint ? 'deck' : 'decklist'}/${id}`;
    fetch(uri, { method: 'GET' })
      .then(response => {
        if (response.ok === true) {
          return response.json();
        }
        throw new Error(`Unexpected status: ${response.status}`);
      })
      .then(json => {
        dispatch(updateDeck(id, json, false));
      }).catch((err: Error) => {
        if (!useDeckEndpoint) {
          return dispatch(fetchPublicDeck(id, true));
        }
        console.log(err);
      });
  };
github zzorba / ArkhamCards / lib / auth.ts View on Github external
import { Platform } from 'react-native';
import Config from 'react-native-config';
import * as Keychain from 'react-native-keychain';
import { authorize, refresh, revoke, prefetchConfiguration, AuthorizeResult, RefreshResult } from 'react-native-app-auth';

const config: any = {
  issuer: Config.OAUTH_SITE,
  clientId: Config.OAUTH_CLIENT_ID,
  clientSecret: Config.OAUTH_CLIENT_SECRET,
  redirectUrl: 'arkhamcards://auth/redirect',
  serviceConfiguration: {
    authorizationEndpoint: `${Config.OAUTH_SITE}oauth/v2/auth`,
    tokenEndpoint: `${Config.OAUTH_SITE}oauth/v2/token`,
    revocationEndpoint: `${Config.OAUTH_SITE}oauth/v2/revoke`,
  },
};

function saveAuthResponse(response: AuthorizeResult | RefreshResult) {
  const serialized = JSON.stringify(response);
  return Keychain.setGenericPassword('arkhamdb', serialized)
    .then(() => {
      return response.accessToken;
    });
github zzorba / ArkhamCards / lib / authApi.ts View on Github external
return getAccessToken().then(accessToken => {
    if (!accessToken) {
      throw new Error('badAccessToken');
    }
    const uri = `${Config.OAUTH_SITE}api/oauth2/deck/load/${id}?access_token=${accessToken}`;
    return fetch(uri, {
      method: 'GET',
    }).then(response => {
      if (response.status === 500) {
        throw new Error('Not Found');
      }
      if (response.status !== 200) {
        throw new Error('Invalid Deck Status');
      }
      return response.json().then(deck => {
        if (deck && deck.id && deck.name && deck.slots) {
          return cleanDeck(deck);
        }
        throw new Error('Invalid Deck Response');
      });
    });
github zzorba / ArkhamCards / lib / auth.ts View on Github external
import { Platform } from 'react-native';
import Config from 'react-native-config';
import * as Keychain from 'react-native-keychain';
import { authorize, refresh, revoke, prefetchConfiguration, AuthorizeResult, RefreshResult } from 'react-native-app-auth';

const config: any = {
  issuer: Config.OAUTH_SITE,
  clientId: Config.OAUTH_CLIENT_ID,
  clientSecret: Config.OAUTH_CLIENT_SECRET,
  redirectUrl: 'arkhamcards://auth/redirect',
  serviceConfiguration: {
    authorizationEndpoint: `${Config.OAUTH_SITE}oauth/v2/auth`,
    tokenEndpoint: `${Config.OAUTH_SITE}oauth/v2/token`,
    revocationEndpoint: `${Config.OAUTH_SITE}oauth/v2/revoke`,
  },
};

function saveAuthResponse(response: AuthorizeResult | RefreshResult) {
  const serialized = JSON.stringify(response);
  return Keychain.setGenericPassword('arkhamdb', serialized)
    .then(() => {
      return response.accessToken;
    });
}

export function getRefreshToken() {
  return Keychain.getGenericPassword()
    .then(creds => {