Files
copernicus/sentinel.py
2026-03-04 14:11:42 +01:00

39 lines
852 B
Python

import requests
class Sentinel:
def __init__ (self, user, pw,
id="cdse-public",
type="password",
auth_url="https://identity.dataspace.copernicus.eu/auth/realms/CDSE/protocol/openid-connect/token"
):
self.user = user;
self.password = pw;
self.auth_url = auth_url;
self.login_data = {
"client_id": id,
"username": self.user,
"password": self.password,
"grant_type": type,
}
def login(self):
response = requests.post(self.auth_url, data=self.login_data);
self.access_token = response.json()["access_token"];
print(f"Login with user {self.user} successful.");
if __name__ == "__main__":
sat = Sentinel("test", "endex");
sat.login();