This commit is contained in:
Hillel Coren 2021-05-13 14:58:42 +03:00
parent ea20e9683b
commit 50fe5e51aa
3 changed files with 12 additions and 26 deletions

View File

@ -53,8 +53,7 @@ class _UserDetailsState extends State<UserDetails>
static const GMAIL_DEFAULT = 0;
static const GMAIL_1_SIGN_IN = 1;
static const GMAIL_2_REQUEST_SCOPE = 2;
static const GMAIL_3_AUTHORIZE_OFFLINE = 4;
static const GMAIL_2_AUTHORIZE = 2;
int _connectGmailStep = GMAIL_DEFAULT;
String _password;
@ -150,23 +149,17 @@ class _UserDetailsState extends State<UserDetails>
});
} else if (_connectGmailStep == GMAIL_1_SIGN_IN) {
print('## STEP 1');
GoogleOAuth.signIn((idToken, accessToken) {
print('## $idToken, $accessToken');
GoogleOAuth.grantOfflineAccess((idToken, accessToken, serverAuthCode) {
print('## id: $idToken, acces: $accessToken, auth: $serverAuthCode');
if (idToken.isEmpty || accessToken.isEmpty) {
GoogleOAuth.signOut();
} else {
setState(() {
_connectGmailStep = GMAIL_2_REQUEST_SCOPE;
_connectGmailStep = GMAIL_2_AUTHORIZE;
});
}
});
} else if (_connectGmailStep == GMAIL_2_REQUEST_SCOPE) {
print('## STEP 2');
GoogleOAuth.requestGmailScope();
setState(() {
_connectGmailStep = GMAIL_3_AUTHORIZE_OFFLINE;
});
} else if (_connectGmailStep == GMAIL_3_AUTHORIZE_OFFLINE) {
} else if (_connectGmailStep == GMAIL_2_AUTHORIZE) {
print('## STEP 3');
final completer = Completer<Null>();
completer.future.catchError((Object error) {
@ -189,10 +182,8 @@ class _UserDetailsState extends State<UserDetails>
gmailButtonLabel = localization.disconnectGmail;
} else if (_connectGmailStep == GMAIL_1_SIGN_IN) {
gmailButtonLabel = localization.step1SignIn;
} else if (_connectGmailStep == GMAIL_2_REQUEST_SCOPE) {
gmailButtonLabel = localization.step2RequestScope;
} else if (_connectGmailStep == GMAIL_3_AUTHORIZE_OFFLINE) {
gmailButtonLabel = localization.step3AuthorizeOffline;
} else if (_connectGmailStep == GMAIL_2_AUTHORIZE) {
gmailButtonLabel = localization.step2Authorize;
}
return EditScaffold(

View File

@ -61,7 +61,7 @@ class UserDetailsVM {
final signedIn = await GoogleOAuth.grantOfflineAccess(
(idToken, accessToken, serverAuthCode) {
print(
'## onConnectGmailPressed: 3 $idToken, $accessToken, $serverAuthCode');
'## id: $idToken, acces: $accessToken, auth: $serverAuthCode');
if (idToken.isEmpty ||
accessToken.isEmpty ||

View File

@ -16,8 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
'en': {
// STARTER: lang key - do not remove comment
'step_1_sign_in': 'Step 1: Sign In',
'step_2_request_scope': 'Step 2: Request Scope',
'step_3_authorize_offline': 'Step 3: Authorize',
'step_2_authorize': 'Step 3: Authorize',
'account_id': 'Account ID',
'migration_not_yet_completed': 'The migration has not yet completed',
'wizard_warning':
@ -60365,13 +60364,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['step_1_sign_in'] ??
_localizedValues['en']['step_1_sign_in'];
String get step2RequestScope =>
_localizedValues[localeCode]['step_2_request_scope'] ??
_localizedValues['en']['step_2_request_scope'];
String get step3AuthorizeOffline =>
_localizedValues[localeCode]['step_3_authorize_offline'] ??
_localizedValues['en']['step_3_authorize_offline'];
String get step2Authorize =>
_localizedValues[localeCode]['step_2_authorize'] ??
_localizedValues['en']['step_2_authorize'];
String lookup(String key) {
final lookupKey = toSnakeCase(key);