Gmail
This commit is contained in:
parent
ea20e9683b
commit
50fe5e51aa
|
|
@ -53,8 +53,7 @@ class _UserDetailsState extends State<UserDetails>
|
||||||
|
|
||||||
static const GMAIL_DEFAULT = 0;
|
static const GMAIL_DEFAULT = 0;
|
||||||
static const GMAIL_1_SIGN_IN = 1;
|
static const GMAIL_1_SIGN_IN = 1;
|
||||||
static const GMAIL_2_REQUEST_SCOPE = 2;
|
static const GMAIL_2_AUTHORIZE = 2;
|
||||||
static const GMAIL_3_AUTHORIZE_OFFLINE = 4;
|
|
||||||
|
|
||||||
int _connectGmailStep = GMAIL_DEFAULT;
|
int _connectGmailStep = GMAIL_DEFAULT;
|
||||||
String _password;
|
String _password;
|
||||||
|
|
@ -150,23 +149,17 @@ class _UserDetailsState extends State<UserDetails>
|
||||||
});
|
});
|
||||||
} else if (_connectGmailStep == GMAIL_1_SIGN_IN) {
|
} else if (_connectGmailStep == GMAIL_1_SIGN_IN) {
|
||||||
print('## STEP 1');
|
print('## STEP 1');
|
||||||
GoogleOAuth.signIn((idToken, accessToken) {
|
GoogleOAuth.grantOfflineAccess((idToken, accessToken, serverAuthCode) {
|
||||||
print('## $idToken, $accessToken');
|
print('## id: $idToken, acces: $accessToken, auth: $serverAuthCode');
|
||||||
if (idToken.isEmpty || accessToken.isEmpty) {
|
if (idToken.isEmpty || accessToken.isEmpty) {
|
||||||
GoogleOAuth.signOut();
|
GoogleOAuth.signOut();
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_connectGmailStep = GMAIL_2_REQUEST_SCOPE;
|
_connectGmailStep = GMAIL_2_AUTHORIZE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (_connectGmailStep == GMAIL_2_REQUEST_SCOPE) {
|
} else if (_connectGmailStep == GMAIL_2_AUTHORIZE) {
|
||||||
print('## STEP 2');
|
|
||||||
GoogleOAuth.requestGmailScope();
|
|
||||||
setState(() {
|
|
||||||
_connectGmailStep = GMAIL_3_AUTHORIZE_OFFLINE;
|
|
||||||
});
|
|
||||||
} else if (_connectGmailStep == GMAIL_3_AUTHORIZE_OFFLINE) {
|
|
||||||
print('## STEP 3');
|
print('## STEP 3');
|
||||||
final completer = Completer<Null>();
|
final completer = Completer<Null>();
|
||||||
completer.future.catchError((Object error) {
|
completer.future.catchError((Object error) {
|
||||||
|
|
@ -189,10 +182,8 @@ class _UserDetailsState extends State<UserDetails>
|
||||||
gmailButtonLabel = localization.disconnectGmail;
|
gmailButtonLabel = localization.disconnectGmail;
|
||||||
} else if (_connectGmailStep == GMAIL_1_SIGN_IN) {
|
} else if (_connectGmailStep == GMAIL_1_SIGN_IN) {
|
||||||
gmailButtonLabel = localization.step1SignIn;
|
gmailButtonLabel = localization.step1SignIn;
|
||||||
} else if (_connectGmailStep == GMAIL_2_REQUEST_SCOPE) {
|
} else if (_connectGmailStep == GMAIL_2_AUTHORIZE) {
|
||||||
gmailButtonLabel = localization.step2RequestScope;
|
gmailButtonLabel = localization.step2Authorize;
|
||||||
} else if (_connectGmailStep == GMAIL_3_AUTHORIZE_OFFLINE) {
|
|
||||||
gmailButtonLabel = localization.step3AuthorizeOffline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EditScaffold(
|
return EditScaffold(
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class UserDetailsVM {
|
||||||
final signedIn = await GoogleOAuth.grantOfflineAccess(
|
final signedIn = await GoogleOAuth.grantOfflineAccess(
|
||||||
(idToken, accessToken, serverAuthCode) {
|
(idToken, accessToken, serverAuthCode) {
|
||||||
print(
|
print(
|
||||||
'## onConnectGmailPressed: 3 $idToken, $accessToken, $serverAuthCode');
|
'## id: $idToken, acces: $accessToken, auth: $serverAuthCode');
|
||||||
|
|
||||||
if (idToken.isEmpty ||
|
if (idToken.isEmpty ||
|
||||||
accessToken.isEmpty ||
|
accessToken.isEmpty ||
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
'en': {
|
'en': {
|
||||||
// STARTER: lang key - do not remove comment
|
// STARTER: lang key - do not remove comment
|
||||||
'step_1_sign_in': 'Step 1: Sign In',
|
'step_1_sign_in': 'Step 1: Sign In',
|
||||||
'step_2_request_scope': 'Step 2: Request Scope',
|
'step_2_authorize': 'Step 3: Authorize',
|
||||||
'step_3_authorize_offline': 'Step 3: Authorize',
|
|
||||||
'account_id': 'Account ID',
|
'account_id': 'Account ID',
|
||||||
'migration_not_yet_completed': 'The migration has not yet completed',
|
'migration_not_yet_completed': 'The migration has not yet completed',
|
||||||
'wizard_warning':
|
'wizard_warning':
|
||||||
|
|
@ -60365,13 +60364,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
_localizedValues[localeCode]['step_1_sign_in'] ??
|
_localizedValues[localeCode]['step_1_sign_in'] ??
|
||||||
_localizedValues['en']['step_1_sign_in'];
|
_localizedValues['en']['step_1_sign_in'];
|
||||||
|
|
||||||
String get step2RequestScope =>
|
String get step2Authorize =>
|
||||||
_localizedValues[localeCode]['step_2_request_scope'] ??
|
_localizedValues[localeCode]['step_2_authorize'] ??
|
||||||
_localizedValues['en']['step_2_request_scope'];
|
_localizedValues['en']['step_2_authorize'];
|
||||||
|
|
||||||
String get step3AuthorizeOffline =>
|
|
||||||
_localizedValues[localeCode]['step_3_authorize_offline'] ??
|
|
||||||
_localizedValues['en']['step_3_authorize_offline'];
|
|
||||||
|
|
||||||
String lookup(String key) {
|
String lookup(String key) {
|
||||||
final lookupKey = toSnakeCase(key);
|
final lookupKey = toSnakeCase(key);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue