FormidableLabs / react-native-app-auth

React native bridge for AppAuth - an SDK for communicating with OAuth2 providers
https://commerce.nearform.com/open-source/react-native-app-auth
MIT License
1.96k stars 438 forks source link

App freezes when calling prefetchConfiguration with no internet connection #401

Open mtroskot opened 4 years ago

mtroskot commented 4 years ago

Issue

When calling prefetchConfiguration with device in airplane mode or with no internet connection the app freezes.

This is the error I get: E/AppAuth: Network error when retrieving discovery document.

config.js file

import { prefetchConfiguration } from 'react-native-app-auth';

const config = {
  warmAndPrefetchChrome: true,
  issuer: 'https://login.microsoftonline.com/1caa43b8-bf09-48b6-9b3c-bd5a56fec019',
  clientId: '5e0b7c9c-aaaa-472a-8ec6-6362c6d56fbe',
  redirectUrl: 'msauth.com.rccl.oauth://auth/',
  additionalParameters: {},
  scopes: ['openid', 'profile', 'email', 'offline_access'],
};

prefetchConfiguration(config);

export default config;

Also tried using try/catch, still the app freezes.

try{
prefetchConfiguration(config);
}catch (error) {
  console.log(error);
} 

Environment

RN: 0.59.4 react-native-app-auth: ^4.4.0

e3bmo3ty commented 4 years ago

any fix ?

kadikraman commented 3 years ago

I think in general we should check on the React Native side whether the app is connected to the internet before triggering this request, since none of the methods would work with no internet... but it's probably sensible to have a fallback, so we could add a timeout to the request.

vikasatappinlay commented 2 years ago

any one have fixed this error [Error: Network error]

tomjoj commented 2 years ago

use in config dangerouslyAllowInsecureHttpRequests: true,