Skip to content

Keycloak authorization: [Error: Data intent is null] #958

@appdeveloper9is

Description

@appdeveloper9is

Issue

When user is authenticated, its redirected back to app and it show this error [Error: Data intent is null]. I am currently using schemes.
When it comes back to app it shows nothing in console.log and this error comes which i mentioned above.

App,js :

const config = {
issuer: 'http://domain.com/realms/NewWorld',
clientId: 'Check',
redirectUrl: 'com.myapp://*',
serviceConfiguration: {
authorizationEndpoint: http://domain.com/realms/NewWorld/protocol/openid-connect/auth,
tokenEndpoint: http://domain.com/realms/NewWorld/protocol/openid-connect/token,

},

scopes: ['openid', 'profile', 'email', 'offline_access'],
};
const App = () => {
const handleLogin = async () => {
try {
const authState = await authorize(config);

 console.log("auth", authState); // Hantera inloggad användare här } catch (error) { console.log("error",error); } 

};

return (

Login with Keycloak


);
};

Android Manifest :

<uses-permission android:name="android.permission.INTERNET" /> <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- must start with example://main/ --> <!-- http://test.example.com/ won't work since http is in a different intent-filter --> <data android:scheme="com.myapp" /> </intent-filter> </activity> <activity android:name="net.openid.appauth.RedirectUriReceiverActivity"> <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.myapp" /> </intent-filter> 

In build.gradle file :

manifestPlaceholders = [ appAuthRedirectScheme: 'com.myapp.auth' ] 

my keycloak website configuration:

Screenshot 2024-04-07 021632

Environment

  • **Your Identity Provider : Keycloak
  • Platform that you're experiencing the issue on: Android
  • Your react-native Version: e.g. 0.73.5
  • Your react-native-app-auth Version: e.g. 7.1.3
  • **Are you using Expo? No

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageWaiting for a member of the team to confirm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions