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
2.04k stars 441 forks source link

{"nativeStackAndroid":[],"userInfo":null,"message":"User cancelled flow","code":"authentication_error"} #996

Open Venkatesh63740 opened 4 months ago

Venkatesh63740 commented 4 months ago

shared image using version 5.1.3 react native 0.66. and used 7.2.0 latest version of npm but the issue is not resolved.("react-native-app-auth")

please anyone provide a fix.

carbonrobot commented 4 months ago

Please submit the details of your bug report or we will not be able to help you troubleshoot the issue.

See https://github.com/FormidableLabs/react-native-app-auth/blob/main/.github/ISSUE_TEMPLATE/Bug_Report.md for information.

Venkatesh63740 commented 4 months ago

Uploading MicrosoftTeams-video.mp4… after the login it is redirect to the app it shows two application and when we click the the 1st app it shows this error {"nativeStackAndroid":[],"userInfo":null,"message":"Parameter grant_type is directly supported via the authorization request builder, use the builder method instead","code":"run_time_exception"}

if we click 2nd app it shows this error {"nativeStackAndroid":[],"userInfo":null,"message":"User cancelled flow","code":"authentication_error"}. <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.app">

<uses-permission android:name="android.permission.INTERNET" />

<application android:usesCleartextTraffic="true" android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:largeHeap="true" tools:replace="android:allowBackup" android:requestLegacyExternalStorage="true" android:theme="@style/AppTheme">

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:exported="true"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity
        android:name="net.openid.appauth.RedirectUriReceiverActivity"
        android:exported="true">
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
              <data android:scheme="https"
              android:host="com.example.app""
              android:path="/callback"/>
    </intent-filter>
</activity>

Please submit the details of your bug report or we will not be able to help you troubleshoot the issue.

See https://github.com/FormidableLabs/react-native-app-auth/blob/main/.github/ISSUE_TEMPLATE/Bug_Report.md for information.

carbonrobot commented 4 months ago

Each provider has specific configurations that are required. Without knowing your configuration, it will be difficult to help you. Please provide the information required in the Bug Report Template.

Venkatesh63740 commented 4 months ago

https://github.com/FormidableLabs/react-native-app-auth/assets/60341301/28fd93cb-d530-43d1-b12e-d105725705ea

using react native 0.66 and "react-native-app-auth": "^6.4.3",

Androidmanefist.xml

<uses-permission android:name="android.permission.INTERNET" />

<application android:usesCleartextTraffic="true" android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:largeHeap="true" tools:replace="android:allowBackup" android:requestLegacyExternalStorage="true" android:theme="@style/AppTheme">

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:exported="true"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity
    android:name="net.openid.appauth.AuthorizationManagementActivity"
   >
    <intent-filter >
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="com.example.appname" android:host="callback" />
    </intent-filter>
</activity>

build.gradle: manifestPlaceholders = [appAuthRedirectScheme: "com.example.appname"]

my config: { "additionalParameters": { "grant_type": "authorization_code" }, "clientId": "{clientid}", "clientSecret": "{secretkey}", "issuer": "https://{myoktasiteurl}/oauth2/default", "redirectUrl": "com.example.appname:/callback", "responseTypes": "code", "scopes": [ "openid", "profile", "offline_access" ], "serviceConfiguration": { "authorizationEndpoint": "https://{myoktasiteurl}/oauth2/default/v1/authorize", "endSessionEndpoint": "https:/{myoktasiteurl}/oauth2/default/v1/logout", "tokenEndpoint": "https://{myoktasiteurl}/oauth2/default/v1/token" }, "useNonce": false, "usePKCE": true }

working fine in iOS but android, it was not redirecting to my app after the login and after while login the okta site from the app if we close and open the app it shows {"nativeStackAndroid":[],"userInfo":null,"message":"User cancelled flow","code":"authentication_error"}

This is iOS config:

CFBundleURLName $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleURLSchemes {myoktasiteurl}