Skip to content

Commit 6f92b44

Browse files
committed
Put oauth client secret into a file
.. and get rid of the -I option of the mailgw script.
1 parent 1ebb8e6 commit 6f92b44

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

doc/user_guide.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ IMAPS_OAUTH:
725725
Connect to an IMAP server over ssl using OAUTH authentication.
726726
Note that this does not support a password in imaps URLs.
727727
Instead it uses only the user and server and a command-line option for
728-
the directory with the files ``access_token``, ``refresh_token``, and
729-
``client_secret``.
728+
the directory with the files ``access_token``, ``refresh_token``,
729+
``client_secret``, and ``client_id``.
730730
By default this directory is ``oauth`` in your tracker home directory. The
731731
access token is tried first and, if expired, the refresh token together
732732
with the client secret is used to retrieve a new access token. Note that
@@ -736,10 +736,9 @@ IMAPS_OAUTH:
736736

737737
imaps_oauth username@server [mailbox]
738738

739-
Note that you also have to specify the OAuth client id with the
740-
``--oauth-client-id`` option on the command line. The refresh and
741-
access tokens (the latter can be left empty) and the client secret need
742-
to be retrieved via cloud provider specific protocols or websites.
739+
The refresh and access tokens (the latter can be left empty), the
740+
client id and the client secret need to be retrieved via cloud provider
741+
specific protocols or websites.
743742

744743
You need the requests_ library installed for OAuth.
745744

roundup/mailgw.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,8 +1462,10 @@ def renew_oauth_tokens(self):
14621462
"""
14631463
with open(os.path.join(self.oauth_path, 'client_secret'), 'r') as f:
14641464
client_secret = f.read().strip()
1465+
with open(os.path.join(self.oauth_path, 'client_id'), 'r') as f:
1466+
client_id = f.read().strip()
14651467
data = dict \
1466-
( client_id = self.oauth_client_id
1468+
( client_id = client_id
14671469
, client_secret = client_secret
14681470
, refresh_token = self.refresh_token
14691471
, grant_type = 'refresh_token'
@@ -1514,7 +1516,6 @@ def do_imap(self, server, user='', password='', mailbox='', **kw):
15141516
# The following are mandatory for oauth and are passed by
15151517
# the command-line handler:
15161518
self.token_endpoint = kw ['token_endpoint']
1517-
self.oauth_client_id = kw ['oauth_client_id']
15181519
for k in range(2):
15191520
t = self.access_token
15201521
s = 'user=%s\1auth=Bearer %s\1\1' % (user, t)

roundup/scripts/roundup_mailgw.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,18 @@
123123
Connect to an IMAP server over ssl using OAUTH authentication.
124124
Note that this does not support a password in imaps URLs.
125125
Instead it uses only the user and server and a command-line option for
126-
the directory with the files 'access_token', 'refresh_token', and
127-
'client_secret'.
126+
the directory with the files 'access_token', 'refresh_token',
127+
'client_secret', and 'client_id'.
128128
By default this directory is 'oauth' in your tracker home directory. The
129129
access token is tried first and, if expired, the refresh token together
130130
with the client secret is used to retrieve a new access token. Note that
131131
both token files need to be *writeable*, the access token is
132132
continuously replaced and some cloud providers may also renew the
133133
refresh token from time to time:
134134
imaps_oauth username@server [mailbox]
135-
Note that you also have to specify the OAuth client id with the
136-
``--oauth-client-id`` option on the command line. The refresh and
137-
access tokens (the latter can be left empty) and the client secret need
138-
to be retrieved via cloud provider specific protocols or websites.
135+
The refresh and access tokens (the latter can be left empty), the
136+
client id and the client secret need to be retrieved via cloud provider
137+
specific protocols or websites.
139138
140139
141140
@@ -154,8 +153,6 @@ def parse_arguments(argv):
154153
cmd.add_argument('-c', '--default_class', default='',
155154
help="Default class of item to create (else the tracker's "
156155
"MAILGW_DEFAULT_CLASS)")
157-
cmd.add_argument('-I', '--oauth-client-id',
158-
help='ID for OAUTH token refresh')
159156
cmd.add_argument('-O', '--oauth-directory',
160157
help='Directory with OAUTH credentials, default "oauth" in '
161158
'tracker home')
@@ -248,7 +245,6 @@ def main(argv):
248245
elif source == 'imaps_oauth':
249246
d.update(ssl = 1, oauth = 1, oauth_path = args.oauth_directory)
250247
d.update(token_endpoint = args.oauth_token_endpoint)
251-
d.update(oauth_client_id = args.oauth_client_id)
252248
mailbox = ''
253249
if len(args.args) > 3:
254250
mailbox = args.args[3]

0 commit comments

Comments
 (0)