mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
commitcloud: strip whitespace from tokens
Summary: If tokens are stored with whitespace around them, sending them as OAuth headers may fail. Make sure we strip them. Reviewed By: mitrandir77 Differential Revision: D8160309 fbshipit-source-id: b403be6b11f25087ebc1ecdbe9a58b7f9dbda2f8
This commit is contained in:
parent
cfd7a429ae
commit
b22cc19d0a
@ -134,15 +134,22 @@ class TokenLocator(object):
|
||||
"""
|
||||
if pycompat.isdarwin and not self.ui.config(
|
||||
'commitcloud', 'user_token_path'):
|
||||
return self._gettokenosx()
|
||||
token = self._gettokenosx()
|
||||
else:
|
||||
return self._gettokenfromfile()
|
||||
token = self._gettokenfromfile()
|
||||
# Ensure token doesn't have any extraneous whitespace around it.
|
||||
if token is not None:
|
||||
token = token.strip()
|
||||
return token
|
||||
|
||||
def settoken(self, token):
|
||||
"""Public API
|
||||
set token
|
||||
it can throw only in case of unexpected error
|
||||
"""
|
||||
# Ensure token doesn't have any extraneous whitespace around it.
|
||||
if token is not None:
|
||||
token = token.strip()
|
||||
if pycompat.isdarwin and not self.ui.config(
|
||||
'commitcloud', 'user_token_path'):
|
||||
self._settokenosx(token)
|
||||
|
Loading…
Reference in New Issue
Block a user