Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RENKU_ODA_TOKEN_FILE token file name #263

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion oda_api/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
FILE_HOME = "file in home"
CONTEXT_FILE = "context file current directory"

class TokenFileName(Enum):
ODA_TOKEN_FILE = ".oda-token"
RENKU_ODA_TOKEN_FILE = "oda-token"

try:
import jwt
except ImportError:
Expand Down Expand Up @@ -329,8 +333,11 @@
if n == TokenLocation.ODA_ENV_VAR:
token = environ['ODA_TOKEN'].strip()
elif n == TokenLocation.FILE_CUR_DIR:
with open(path.join(getcwd(), ".oda-token")) as ft:
with open(path.join(getcwd(), TokenFileName.ODA_TOKEN_FILE.value)) as ft:
token = ft.read().strip()
if token is None:
with open(path.join(getcwd(), TokenFileName.RENKU_ODA_TOKEN_FILE.value)) as ft:
token = ft.read().strip()

Check warning on line 340 in oda_api/token.py

View check run for this annotation

Codecov / codecov/patch

oda_api/token.py#L339-L340

Added lines #L339 - L340 were not covered by tests
elif n == TokenLocation.FILE_HOME:
with open(path.join(environ["HOME"], ".oda-token")) as ft:
token = ft.read().strip()
Expand Down
Loading