Skip to content

Commit 9d84f66

Browse files
committed
Adding reading of token json
1 parent 989156a commit 9d84f66

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

stashcp.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,20 @@ def getToken():
119119

120120
if 'TOKEN' in os.environ:
121121
scitoken_file = os.environ['TOKEN']
122+
123+
# If the scitoken file is relative, then assume it's relative
124+
# to the _CONDOR_CREDS directory.
125+
if not os.path.isabs(scitoken_file) and "_CONDOR_CREDS" in os.environ:
126+
os.path.join(os.environ['_CONDOR_CREDS'], scitoken_file)
122127

123128
if not scitoken_file or not os.path.exists(scitoken_file):
124129
logging.info("Unable to find token file")
125130
return None
126131

132+
# Read in the JSON
127133
with open(scitoken_file, 'r') as scitoken_obj:
128-
scitoken_contents = scitoken_obj.read().strip()
134+
token_json = json.load(scitoken_obj)
135+
scitoken_contents = token_json['access_token']
129136

130137
return scitoken_contents
131138

0 commit comments

Comments
 (0)