Closed robstewart57 closed 2 years ago
I think I can close this. I hadn't spotted in the offlineimap.conf
sample file this value:
oauth2_access_token_eval = get_access_token("accountname")
So rather than using oauth2_access_token
I should have used oauth2_access_token_eval
. This is unlike (i.e. the source of my confusion) remotepasseval
which supports either a string directly in the .conf
file or a Python function name, defined elsewhere in the pythonfile
, to be evaluated.
General informations
offlineimap -V
): 8.0.0 (GitHub commit e70d3992a0e9bb0fcdf3c94e1edf25a4124dfcd2 )Configuration file offlineimaprc
pythonfile (if any)
Logs, error
The error is that the output from the
oauth2ms --no-browser
command (which returns an OAuth token) is not assigned tooauth2_access_token
oroauth2_refresh_token
in the offlineimap configuration file. After doing some digging inIMAP.py
in the offlineimap3 implementation, it appears that simply the string "get_token()" is assigned tooauth2_access_token
andoauth2_refresh_token
.So it appears that the
get_token()
function is not evaluated to a string, simply the string "get_token()" is assigned in the configuration file.However the
get_pass(account)
function is evaluated to a password string, as expected, and assigned toremotepasseval
in the offlineimap configuration file.Possible bug
The code logic for
getpassword
is a bit different to the functions for gettings the oauth information.https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/repository/IMAP.py#L375
However
getoauth2_access_token
is:However
if access_token is None
will not betrue
becauseaccess_token
will be the string "get_token()". Should this function not be the opposite? e.g.The same suggestion for the
getoauth2_refresh_token
function: https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/repository/IMAP.py#L308This potential bug might be the root cause for the issue https://github.com/OfflineIMAP/offlineimap/issues/667 .