start at geo-db
This commit is contained in:
38
sentinel.py
Normal file
38
sentinel.py
Normal file
@@ -0,0 +1,38 @@
|
||||
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();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user