-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support to
clearCache
and clearCookies
directly from `Oau…
…thWebAuth.instance`. - Full code refactor to use `BaseConfiguration(...)` and `OauthConfiguration(...)`. See readme for migration. - SDK constraints updated to `sdk: ">=2.19.0 <3.0.0"` and `flutter: ">=2.0.0"`. - Fixed bug in redirect url handling that caused `invalid_grant` due to content after `#` in url.
- Loading branch information
1 parent
952225a
commit a4c0050
Showing
22 changed files
with
960 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d | ||
|
||
COCOAPODS: 1.11.3 | ||
COCOAPODS: 1.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import 'dart:convert'; | |
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
// ignore: depend_on_referenced_packages | ||
import 'package:oauth2/oauth2.dart'; | ||
import 'package:oauth_webauth/oauth_webauth.dart'; | ||
|
||
|
@@ -87,10 +88,10 @@ class _AuthSampleScreenState extends State<AuthSampleScreen> { | |
), | ||
ElevatedButton( | ||
onPressed: kIsWeb ? null : loginV1, | ||
child: const Text( | ||
'Login variant 1${kIsWeb ? '(NOT SUPPORTED ON WEB)' : ''}'), | ||
style: ButtonStyle( | ||
backgroundColor: MaterialStateProperty.all(Colors.green)), | ||
child: const Text( | ||
'Login variant 1${kIsWeb ? '(NOT SUPPORTED ON WEB)' : ''}'), | ||
), | ||
const SizedBox(height: 4), | ||
ElevatedButton( | ||
|
@@ -106,33 +107,34 @@ class _AuthSampleScreenState extends State<AuthSampleScreen> { | |
|
||
void loginV1() async { | ||
final result = await OAuthWebScreen.start( | ||
context: context, | ||
authorizationEndpointUrl: authorizationEndpointUrl, | ||
tokenEndpointUrl: tokenEndpointUrl, | ||
clientSecret: clientSecret, | ||
clientId: clientId, | ||
redirectUrl: redirectUrl, | ||
scopes: scopes, | ||
promptValues: const ['login'], | ||
loginHint: '[email protected]', | ||
onCertificateValidate: (certificate) { | ||
///This is recommended | ||
/// Do certificate validations here | ||
/// If false is returned then a CertificateException() will be thrown | ||
return true; | ||
}, | ||
textLocales: { | ||
///Optionally texts can be localized | ||
BaseWebView.backButtonTooltipKey: 'Ir atrás', | ||
BaseWebView.forwardButtonTooltipKey: 'Ir adelante', | ||
BaseWebView.reloadButtonTooltipKey: 'Recargar', | ||
BaseWebView.clearCacheButtonTooltipKey: 'Limpiar caché', | ||
BaseWebView.closeButtonTooltipKey: 'Cerrar', | ||
BaseWebView.clearCacheWarningMessageKey: | ||
'¿Está seguro que desea limpiar la caché?', | ||
}, | ||
contentLocale: contentLocale, | ||
); | ||
context: context, | ||
configuration: OauthConfiguration( | ||
authorizationEndpointUrl: authorizationEndpointUrl, | ||
tokenEndpointUrl: tokenEndpointUrl, | ||
clientSecret: clientSecret, | ||
clientId: clientId, | ||
redirectUrl: redirectUrl, | ||
scopes: scopes, | ||
promptValues: const ['login'], | ||
loginHint: '[email protected]', | ||
onCertificateValidate: (certificate) { | ||
///This is recommended | ||
/// Do certificate validations here | ||
/// If false is returned then a CertificateException() will be thrown | ||
return true; | ||
}, | ||
textLocales: { | ||
///Optionally texts can be localized | ||
BaseConfiguration.backButtonTooltipKey: 'Ir atrás', | ||
BaseConfiguration.forwardButtonTooltipKey: 'Ir adelante', | ||
BaseConfiguration.reloadButtonTooltipKey: 'Recargar', | ||
BaseConfiguration.clearCacheButtonTooltipKey: 'Limpiar caché', | ||
BaseConfiguration.closeButtonTooltipKey: 'Cerrar', | ||
BaseConfiguration.clearCacheWarningMessageKey: | ||
'¿Está seguro que desea limpiar la caché?', | ||
}, | ||
contentLocale: contentLocale, | ||
)); | ||
isLoading = false; | ||
if (result != null) { | ||
if (result is Credentials) { | ||
|
@@ -148,50 +150,52 @@ class _AuthSampleScreenState extends State<AuthSampleScreen> { | |
|
||
void loginV2() { | ||
OAuthWebScreen.start( | ||
context: context, | ||
authorizationEndpointUrl: authorizationEndpointUrl, | ||
tokenEndpointUrl: tokenEndpointUrl, | ||
clientSecret: clientSecret, | ||
clientId: clientId, | ||
redirectUrl: redirectUrl, | ||
scopes: scopes, | ||
promptValues: const ['login'], | ||
loginHint: '[email protected]', | ||
onCertificateValidate: (certificate) { | ||
///This is recommended | ||
/// Do certificate validations here | ||
/// If false is returned then a CertificateException() will be thrown | ||
return true; | ||
}, | ||
textLocales: { | ||
///Optionally text can be localized | ||
BaseWebView.backButtonTooltipKey: 'Ir atrás', | ||
BaseWebView.forwardButtonTooltipKey: 'Ir adelante', | ||
BaseWebView.reloadButtonTooltipKey: 'Recargar', | ||
BaseWebView.clearCacheButtonTooltipKey: 'Limpiar caché', | ||
BaseWebView.closeButtonTooltipKey: 'Cerrar', | ||
BaseWebView.clearCacheWarningMessageKey: | ||
'¿Está seguro que desea limpiar la caché?', | ||
}, | ||
contentLocale: contentLocale, | ||
onSuccess: (credentials) { | ||
isLoading = false; | ||
setState(() { | ||
authResponse = getPrettyCredentialsJson(credentials); | ||
}); | ||
}, | ||
onError: (error) { | ||
isLoading = false; | ||
setState(() { | ||
authResponse = error.toString(); | ||
}); | ||
}, | ||
onCancel: () { | ||
isLoading = false; | ||
setState(() { | ||
authResponse = 'User cancelled authentication'; | ||
}); | ||
}); | ||
context: context, | ||
configuration: OauthConfiguration( | ||
authorizationEndpointUrl: authorizationEndpointUrl, | ||
tokenEndpointUrl: tokenEndpointUrl, | ||
clientSecret: clientSecret, | ||
clientId: clientId, | ||
redirectUrl: redirectUrl, | ||
scopes: scopes, | ||
promptValues: const ['login'], | ||
loginHint: '[email protected]', | ||
onCertificateValidate: (certificate) { | ||
///This is recommended | ||
/// Do certificate validations here | ||
/// If false is returned then a CertificateException() will be thrown | ||
return true; | ||
}, | ||
textLocales: { | ||
///Optionally text can be localized | ||
BaseConfiguration.backButtonTooltipKey: 'Ir atrás', | ||
BaseConfiguration.forwardButtonTooltipKey: 'Ir adelante', | ||
BaseConfiguration.reloadButtonTooltipKey: 'Recargar', | ||
BaseConfiguration.clearCacheButtonTooltipKey: 'Limpiar caché', | ||
BaseConfiguration.closeButtonTooltipKey: 'Cerrar', | ||
BaseConfiguration.clearCacheWarningMessageKey: | ||
'¿Está seguro que desea limpiar la caché?', | ||
}, | ||
contentLocale: contentLocale, | ||
onSuccessAuth: (credentials) { | ||
isLoading = false; | ||
setState(() { | ||
authResponse = getPrettyCredentialsJson(credentials); | ||
}); | ||
}, | ||
onError: (error) { | ||
isLoading = false; | ||
setState(() { | ||
authResponse = error.toString(); | ||
}); | ||
}, | ||
onCancel: () { | ||
isLoading = false; | ||
setState(() { | ||
authResponse = 'User cancelled authentication'; | ||
}); | ||
}), | ||
); | ||
} | ||
|
||
String getPrettyCredentialsJson(Credentials credentials) { | ||
|
Oops, something went wrong.