Bug: I am getting an error - ERR_STATES_NOT_MATCH on Android
Keyurhardas opened this issue · comments
Capacitor version:
Latest Dependencies:
@capacitor/cli: 3.4.3
@capacitor/core: 3.4.3
@capacitor/android: 3.4.3
@capacitor/ios: 3.4.3
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/core: 3.4.3
@capacitor/cli: 3.4.3
@capacitor/android: 3.4.3
Library version:
- 3.0.1
OAuth Provider:
- Azure AD (B2C)
Your Plugin Configuration
{
appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
authorizationBaseUrl:
'https://login.microsoftonline.com/'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/v2.0/authorize',
accessTokenEndpoint:
'https://login.microsoftonline.com/'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/v2.0/token',
responseType: 'token',
scope: 'User.Read',
pkceEnabled: true,
logsEnabled: true,
web: {
responseType: 'token id_token',
redirectUrl: 'http://localhost:8100',
accessTokenEndpoint: '',
},
android: {
redirectUrl: 'msauth://id.package.my/xxxxxxxxxxxxxxxxxxxxxxxxxxxx' // URL encoded signature hash
accessTokenEndpoint: '',
handleResultOnNewIntent: true,
handleResultOnActivityResult: true,
},
ios: {
redirectUrl: 'msauth.com.xxxxx://auth',
},
};
Affected Platform(s):
- Android
- Version/API Level: API 30
- Device Model: Pixel 2
- Content of your
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=id.package.my.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask">
<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" />
<data android:scheme="@string/custom_url_scheme" android:host="@string/custom_host" />
</intent-filter>
</activity>
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity" android:exported="true">
<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="@string/custom_url_scheme" android:host="@string/custom_host" />
</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" />
<data android:scheme="@string/azure_b2c_scheme" android:host="@string/package_name" android:path="@string/azure_b2c_signature_hash" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
</application>
<uses-permission android:name="android.permission.INTERNET" />
Current Behavior
I am getting an error - ERR_STATES_NOT_MATCH in my android app. When I change the responseType to "code" then I get a response from the server with the same configurations. I am not sure what am I doing wrong in here. On the web with responseType as "token" I get the access token but on android I get this error with responseType as "token".
Expected Behavior
I need to get the access token whenever the user logs in through the sign in page on Android. I have followed all the steps from the default android setup but I am not able to get the access token on Android.
Turns out there was an issue with my accessTokenEndpoint. My bad.
Everything is now working fine on Android with the configurations mentioned.
Awesome plugin, Thanks!
Hi @Keyurhardas will you please help me how you solved the issue. I am also facing the same issue