Skip to content

Commit c27c640

Browse files
committed
add cli and doc
1 parent 39e16da commit c27c640

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

bin/get-bearer-token

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python3
2+
3+
import click
4+
import requests
5+
6+
def get_access_token(username: str, password: str) -> str:
7+
data = {
8+
"client_id": "cdse-public",
9+
"username": username,
10+
"password": password,
11+
"grant_type": "password",
12+
}
13+
try:
14+
r = requests.post(
15+
"https://identity.dataspace.copernicus.eu/auth/realms/CDSE/protocol/openid-connect/token",
16+
data=data,
17+
)
18+
r.raise_for_status()
19+
except Exception as e:
20+
raise Exception(
21+
f"Access token creation failed. Response from the server was: {r.json()}"
22+
)
23+
return r.json()["access_token"]
24+
25+
@click.command(
26+
short_help="Get bearer token",
27+
help="Get a bearer token for the Copernicus Data Space Ecosystem ",
28+
)
29+
@click.option(
30+
"--username",
31+
help="Username for the Copernicus Data Space Ecosystem",
32+
required=True,
33+
)
34+
@click.option(
35+
"--password",
36+
help="Password for the Copernicus Data Space Ecosystem",
37+
required=True,
38+
)
39+
def get_bearer_token(username: str, password: str) -> str:
40+
41+
return print(get_access_token(username, password))
42+
43+
if __name__ == "__main__":
44+
get_bearer_token()

docs/app/stage-in/app.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# Stage-in
1+
# Sentinel-2 Level-1C stage-in
2+
3+
While there are many options to consume Sentinel-2 Level-2A in a Cloud native processing approach, the Level-1C data must instead be staged from the Copernicus Data Space Ecosystem.
4+

practice-labs/01 - Stage-and-cog.ipynb

Whitespace-only changes.

0 commit comments

Comments
 (0)