diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index 7f50b152..76e774dd 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -756,8 +756,9 @@ class GoTrueClient { } final errorDescription = url.queryParameters['error_description']; + final errorCode = url.queryParameters['error_code']; if (errorDescription != null) { - throw AuthException(errorDescription); + throw AuthException(errorDescription, statusCode: errorCode); } if (_flowType == AuthFlowType.pkce) { diff --git a/packages/gotrue/test/client_test.dart b/packages/gotrue/test/client_test.dart index 35fae8a0..79951b76 100644 --- a/packages/gotrue/test/client_test.dart +++ b/packages/gotrue/test/client_test.dart @@ -137,6 +137,7 @@ void main() { fail('getSessionFromUrl did not throw exception'); } on AuthException catch (error) { expect(error.message, errorMessage); + expect(error.statusCode, '401'); } catch (error) { fail( 'getSessionFromUrl threw ${error.runtimeType} instead of AuthException');