auth
This module contains authentication-related functions.
get_copernicus_credentials #
get_copernicus_credentials(logger: Logger = LOGGER) -> tuple[str, str] | None
Retrieves Copernicus credentials from environment variables or prompts the user.
This function first checks for COPERNICUS_USERNAME and COPERNICUS_PASSWORD
environment variables. If they are not set, it interactively prompts the user
for their username and password.
Using environment variables is recommended for security and to comply with the 12-factor app methodology, which separates configuration from code. This prevents hardcoding sensitive information and makes the application more portable across different environments (development, testing, production).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger
|
Logger
|
Logger instance. |
LOGGER
|
Returns:
| Type | Description |
|---|---|
tuple[str, str] | None
|
A tuple containing the username and password, or None if they could not be |
tuple[str, str] | None
|
obtained. |
Source code in src/geospatial_tools/auth.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
get_copernicus_token #
get_copernicus_token(logger: Logger = LOGGER) -> str | None
Retrieves an access token from the Copernicus Data Space Ecosystem.
This function uses the credentials obtained from get_copernicus_credentials
to request an access token from the authentication endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger
|
Logger
|
Logger instance. |
LOGGER
|
Returns:
| Type | Description |
|---|---|
str | None
|
The access token as a string, or None if authentication fails. |
Source code in src/geospatial_tools/auth.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |