@@ -332,10 +332,17 @@ private String arrayToString(ReadableArray array) {
332332 * Read raw token response into a React Native map to be passed down the bridge
333333 */
334334 private WritableMap tokenResponseToMap (TokenResponse response ) {
335+ WritableMap map = Arguments .createMap ();
336+
337+ map .putString ("accessToken" , response .accessToken );
338+
339+ if (response .accessTokenExpirationTime != null ) {
340+ Date expirationDate = new Date (response .accessTokenExpirationTime );
341+ SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssZ" );
342+ String expirationDateString = formatter .format (expirationDate );
343+ map .putString ("accessTokenExpirationDate" , expirationDateString );
344+ }
335345
336- Date expirationDate = new Date (response .accessTokenExpirationTime );
337- SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssZ" );
338- String expirationDateString = formatter .format (expirationDate );
339346 WritableMap additionalParametersMap = Arguments .createMap ();
340347
341348 if (!response .additionalParameters .isEmpty ()) {
@@ -348,9 +355,6 @@ private WritableMap tokenResponseToMap(TokenResponse response) {
348355 }
349356 }
350357
351- WritableMap map = Arguments .createMap ();
352- map .putString ("accessToken" , response .accessToken );
353- map .putString ("accessTokenExpirationDate" , expirationDateString );
354358 map .putMap ("additionalParameters" , additionalParametersMap );
355359 map .putString ("idToken" , response .idToken );
356360 map .putString ("refreshToken" , response .refreshToken );
@@ -423,4 +427,4 @@ public void onNewIntent(Intent intent) {
423427 public String getName () {
424428 return "RNAppAuth" ;
425429 }
426- }
430+ }
0 commit comments