Skip to content

Conversation

@eliaslecomte
Copy link
Contributor

@eliaslecomte eliaslecomte commented May 19, 2022

Fixes when targeting Android SDK 31 (Android 12), it's not possible to login via browser, on Android 7, 8, 9, 10 or 11 when you have Opera or Opera Beta installed.
Authorising immediately fails with an error (code: no_browser_found, message: Error not specified).

Description

Bumps the net.openid:appauth library from 0.8.1 to 0.11.1 (https://github.com/openid/AppAuth-Android/tags).

Steps to verify

  1. Use targetSdk 31 to build for Android 12
  2. Install Opera or Opera beta on a phone with Android 7, 8, 9, 10 or 11
  3. Launch webbrowser for login by calling authorize
  4. Promise is rejected and the web browser never launches

@eliaslecomte
Copy link
Contributor Author

The androidx.browser dependency is also outdated (implementation 'androidx.browser:browser:1.2.0'), I think it's best to update this as well.

@eliaslecomte eliaslecomte changed the title dep(android): update net.openid:appauth from 0.8.1 to 0.11.1 Draft: dep(android): update net.openid:appauth from 0.8.1 to 0.11.1 May 20, 2022
@eliaslecomte eliaslecomte changed the title Draft: dep(android): update net.openid:appauth from 0.8.1 to 0.11.1 dep(android): update net.openid:appauth from 0.8.1 to 0.11.1 May 20, 2022
Copy link
Contributor

@kadikraman kadikraman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@timostroehlein
Copy link

Are there any plans to release this fix soon? Because we are experiencing this exact issue on production

@bitcrumb
Copy link

bitcrumb commented Jun 15, 2022

@timostroehlein We integrated patch-package in our project. This allows you to define patches (diffs) in your project which are applied post-install. It's great for addressing issues like these while you are awaiting on official release with the fix :)

For instance:

diff --git a/node_modules/react-native-app-auth/android/build.gradle b/node_modules/react-native-app-auth/android/build.gradle
index 85fb638..3eff1a2 100644
--- a/node_modules/react-native-app-auth/android/build.gradle
+++ b/node_modules/react-native-app-auth/android/build.gradle
@@ -56,6 +56,6 @@ repositories {
 dependencies {
     //noinspection GradleDynamicVersion
     implementation 'com.facebook.react:react-native:+'  // From node_modules
-    implementation 'net.openid:appauth:0.8.1'
-    implementation 'androidx.browser:browser:1.2.0'
+    implementation 'net.openid:appauth:0.11.1'
+    implementation 'androidx.browser:browser:1.4.0'
 }
diff --git a/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java b/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java
index 8736904..207c176 100644
--- a/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java
+++ b/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java
@@ -784,11 +784,9 @@ public class RNAppAuthModule extends ReactContextBaseJavaModule implements Activ
         final Activity currentActivity = getCurrentActivity();
 
         EndSessionRequest.Builder endSessionRequestBuilder =
-                new EndSessionRequest.Builder(
-                        serviceConfiguration,
-                        idTokenHint,
-                        Uri.parse(postLogoutRedirectUri)
-                );
+                new EndSessionRequest.Builder(serviceConfiguration)
+                        .setIdTokenHint(idTokenHint)
+                        .setPostLogoutRedirectUri(Uri.parse(postLogoutRedirectUri));
 
         if (additionalParametersMap != null) {
             if (additionalParametersMap.containsKey("state")) {
diff --git a/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/utils/EndSessionResponseFactory.java b/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/utils/EndSessionResponseFactory.java
index 4cad2da..1bc35c7 100644
--- a/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/utils/EndSessionResponseFactory.java
+++ b/node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/utils/EndSessionResponseFactory.java
@@ -13,8 +13,10 @@ public final class EndSessionResponseFactory {
         WritableMap map = Arguments.createMap();
 
         map.putString("state", response.state);
-        map.putString("idTokenHint", response.request.idToken);
-        map.putString("postLogoutRedirectUri", response.request.redirectUri.toString());
+        map.putString("idTokenHint", response.request.idTokenHint);
+        if (response.request.postLogoutRedirectUri != null) {
+            map.putString("postLogoutRedirectUri", response.request.postLogoutRedirectUri.toString());
+        }
 
         return map;
     }
diff --git a/node_modules/react-native-app-auth/index.d.ts b/node_modules/react-native-app-auth/index.d.ts
index 7079aab..f7d4ad9 100644
--- a/node_modules/react-native-app-auth/index.d.ts
+++ b/node_modules/react-native-app-auth/index.d.ts
@@ -172,9 +172,11 @@ type AppAuthErrorCode =
   | 'service_configuration_fetch_error'
   | 'authentication_failed'
   | 'token_refresh_failed'
+  | 'token_exchange_failed'
   | 'registration_failed'
   | 'browser_not_found'
-  | 'end_session_failed';
+  | 'end_session_failed'
+  | 'authentication_error';
 
 type ErrorCode =
   | OAuthAuthorizationErrorCode

@timostroehlein
Copy link

That's great! Thanks for the Information, i will do that

@kadikraman
Copy link
Contributor

This is published in the next release candidate 7.0.0-rc1 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants