I have configured my app to sign in to ArcGIS online via OAuth according to sample. When I try to access portal (namely, get token) on Android emulator, I experience the following behaviour.
This is very confusing behaviour. Nevertheless, token in received correctly and is available in my code.
Here is what I see in Flutter log:
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
D/FlutterLocationService(25127): Creating service.
D/FlutterLocationService(25127): Binding to location service.
Debug service listening on ws://127.0.0.1:54747/7nhbvLo_1Ck=/ws
Syncing files to device sdk gphone64 x86 64...
D/ProfileInstaller(25127): Installing profile for com.esri.[my-app-id]
I/PlatformViewsController(25127): Using hybrid composition for platform view: 0
D/CompatibilityChangeReporter(25127): Compat change id reported: 236825255; UID 10191; state: ENABLED
E/EGL_emulation(25127): eglQueryContext 32c0 EGL_BAD_ATTRIBUTE
E/EGL_emulation(25127): tid 25127: eglQueryContext(2146): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/MapViewRenderer(25127): Starting pulse
I/flutter (25127): Getting token
I/flutter (25127): Creating OAuthUserCredential
D/EGL_emulation(25127): app_time_stats: avg=3309.65ms min=164.96ms max=6454.35ms count=2
D/EGL_emulation(25127): app_time_stats: avg=3305.84ms min=166.88ms max=6444.81ms count=2
D/EGL_emulation(25127): app_time_stats: avg=1767.54ms min=59.52ms max=6441.73ms count=4
I/MapViewRenderer(25127): Stopping pulse
D/EGL_emulation(25127): app_time_stats: avg=243.07ms min=17.80ms max=1832.81ms count=9
D/EGL_emulation(25127): app_time_stats: avg=243.33ms min=14.82ms max=1836.10ms count=9
D/EGL_emulation(25127): app_time_stats: avg=242.64ms min=19.78ms max=1825.41ms count=9
I/flutter (25127): Getting token info
I/flutter (25127): accessToken: 3NKHt6...
I/MapViewRenderer(25127): Resumed by user. Texture view available: true
W/OpenGLRenderer(25127): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
W/OpenGLRenderer(25127): Failed to initialize 101010-2 format, error = EGL_SUCCESS
E/OpenGLRenderer(25127): Unable to match the desired swap behavior.
D/EGL_emulation(25127): app_time_stats: avg=24751.84ms min=24751.84ms max=24751.84ms count=1
D/EGL_emulation(25127): app_time_stats: avg=24763.88ms min=24763.88ms max=24763.88ms count=1
I/MapViewRenderer(25127): Starting pulse
D/EGL_emulation(25127): app_time_stats: avg=27904.54ms min=157.61ms max=55651.45ms count=2
D/EGL_emulation(25127): app_time_stats: avg=27900.98ms min=150.63ms max=55651.33ms count=2
D/EGL_emulation(25127): app_time_stats: avg=18624.16ms min=93.41ms max=55642.82ms count=3
Notes:
Here is the video describing what's happening.
Solved! Go to Solution.
I added a note internally to make sure we upgrade flutter_web_auth_2 for the next release.
We did look at other OAuth packages, but we didn't completely integrate them with our workflow. I don't remember why we went with flutter_web_auth_2. But all of this discussion has given us a pretty good reason to reconsider.
I couldn't find any other way to dismiss the login view.
I found another thing to try. In your call to the OAuthUserConfiguration constructor, add the flag "preferPrivateWebBrowserSession: true". For example, here's adding this flag in the Sample Viewer:
final _oauthUserConfiguration = OAuthUserConfiguration(
portalUri: Uri.parse('https://www.arcgis.com'),
clientId: 'T0A3SudETrIQndd2',
redirectUri: Uri.parse('my-ags-flutter-app://auth'),
preferPrivateWebBrowserSession: true,
);
With a private browser session, the web view gets closed after you log in successfully (or cancel). That keeps it from getting in the way. I'm sure this will solve the odd behaviour from your video with the Sample Viewer, but I'm not certain it will solve the problem with your test app.
Tried to use 'preferPrivateWebBrowserSession: true' param. Results are the following:
I've removed both apps before testing, just in case.