MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
269 stars 239 forks source link

unexpectedly failed to authorize #385

Closed mgeee closed 1 year ago

mgeee commented 1 year ago

Hi appauth-team,

Iam totally confused and unfortunately can't help myself. Hope you guy's have the right questions to fix my issue.

Since yesterday my openid-connect implementation to keycloak fails. Everything worked nicely until last week. The problem is, I don't exactly know what i did changed. However, I'm sure updated Flutter, but I think authorization did worked afterwards. Furthermore I didn't touch the auth-implementation.

Postman tests with the same config-params are still working. I checked the android- and ios-setup, but everything is like in the flutter_appauth-readme.md. I also have done that flutter clean stuff, you sometimes have to do, but without any success.

The Stacktrace is the following (in android-simulator and ios-simulator):

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(authorize_and_exchange_code_failed, Failed to authorize: Issued at time is more than 600 seconds before or after the current time, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)<asynchronous suspension>
#2      MethodChannelFlutterAppAuth.authorizeAndExchangeCode (package:flutter_appauth_platform_interface/src/method_channel_flutter_appauth.dart:37:43)
<asynchronous suspension>
#3      AppAuthApiImpl.login (package:appauthtest/app_auth_auth_api.dart:50:20)
<asynchronous suspension>

The failing line is:

final result = await _appAuth.authorizeAndExchangeCode(
      AuthorizationTokenRequest(CLIENT_ID, REDIRECT_URI,
          issuer: ISSUER,
          scopes: ['openid'],
          preferEphemeralSession: true),
    );

flutter doctor -v:

 ~/dev/opt/flutter  stable ⇣11  flutter doctor -v                                 ✔  20:14:54
[✓] Flutter (Channel stable, 3.3.2, on macOS 12.6 21G115 darwin-arm, locale de-DE)
    • Flutter version 3.3.2 on channel stable at /Users/mgrefe/dev/opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (vor 7 Wochen), 2022-09-14 08:46:55 -0500
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    • Android SDK at /Users/mgrefe/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2021.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.72.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • B20C3BBB-F613-40A1-A5F7-514F6DBD278E • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS
      12.6 21G115 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google
      Chrome 107.0.5304.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

I am happy about all hints!

mgeee commented 1 year ago

i've found the problem. Servers time wasn't in sync, because of time change here in germany to winter-time. f***, it costs me hours of troubleshooting... But now, i'm happy, to have that learning done 👍 📦