11import invariant from 'invariant' ;
2- import { NativeModules } from 'react-native' ;
2+ import { NativeModules , Platform } from 'react-native' ;
33
44const { RNAppAuth } = NativeModules ;
55
@@ -19,14 +19,18 @@ export const authorize = ({ issuer, redirectUrl, clientId, scopes, additionalPar
1919 validateRedirectUrl ( redirectUrl ) ;
2020 // TODO: validateAdditionalParameters
2121
22- return RNAppAuth . authorize (
22+ const nativeMethodArguments = [
2323 issuer ,
2424 redirectUrl ,
2525 clientId ,
2626 scopes ,
27- additionalParameters ,
28- dangerouslyAllowInsecureHttpRequests
29- ) ;
27+ additionalParameters
28+ ]
29+ if ( Platform . OS === 'android' ) {
30+ nativeMethodArguments . push ( dangerouslyAllowInsecureHttpRequests ) ;
31+ }
32+
33+ return RNAppAuth . authorize ( ...nativeMethodArguments ) ;
3034} ;
3135
3236export const refresh = (
@@ -40,15 +44,20 @@ export const refresh = (
4044 invariant ( refreshToken , 'Please pass in a refresh token' ) ;
4145 // TODO: validateAdditionalParameters
4246
43- return RNAppAuth . refresh (
47+ const nativeMethodArguments = [
4448 issuer ,
4549 redirectUrl ,
4650 clientId ,
4751 refreshToken ,
4852 scopes ,
49- additionalParameters ,
50- dangerouslyAllowInsecureHttpRequests
51- ) ;
53+ additionalParameters
54+ ] ;
55+
56+ if ( Platform . OS === 'android' ) {
57+ nativeMethodArguments . push ( dangerouslyAllowInsecureHttpRequests ) ;
58+ }
59+
60+ return RNAppAuth . refresh ( ...nativeMethodArguments ) ;
5261} ;
5362
5463export const revoke = async ( { clientId, issuer } , { tokenToRevoke, sendClientId = false } ) => {
0 commit comments