Skip to content

Commit

Permalink
Add .dodsrc and .urs_cookies files
Browse files Browse the repository at this point in the history
  • Loading branch information
battistowx committed Mar 13, 2024
1 parent 8fe6097 commit 97c0925
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions earthaccess/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import importlib.metadata
import logging
import os
import platform
import shutil
from netrc import NetrcParseError
from pathlib import Path
from typing import Any, Dict, List, Optional
Expand Down Expand Up @@ -370,6 +372,20 @@ def _persist_user_credentials(self, username: str, password: str) -> bool:
my_netrc = Netrc(str(netrc_path))
my_netrc["urs.earthdata.nasa.gov"] = {"login": username, "password": password}
my_netrc.save()
netrc_file = Path.home() / '.netrc'

# Create and write .urs_cookies file
urs_cookies_file = Path.home() / '.urs_cookies'
urs_cookies_file.write_text('')

# Create and write to .dodsrc file
dodsrc_file = Path.home() / '.dodsrc'
dodsrc_contents = f"HTTP.COOKIEJAR={urs_cookies_file}\nHTTP.NETRC={netrc_file}"
dodsrc_file.write_text(dodsrc_contents)

if platform.system() == "Windows":
shutil.copy2(dodsrc_file, Path.cwd())

return True

def _get_cloud_auth_url(
Expand Down

0 comments on commit 97c0925

Please sign in to comment.