Forum

Message Boards Message Boards

Back

PHP login to EO finder

Toggle
PHP login to EO finder
Answer
13 January 2019 4:23
Hello, 

Is there a easy way to login via PHP (curl or other script like guzzle) to eosfinder to receive the token for downloading images?

Thank you
0 (0 Votes)

RE: PHP login to EO finder
Answer
13 January 2019 4:48 as a reply to SASU SEBASTIAN ANDREI.
Hello,

Please read the following: https://creodias.eu/eo-data-finder-api-manual
You should be registered CREODIAS user to be able to download the products.

Regards,
Marcin Gil
0 (0 Votes)

RE: PHP login to EO finder
Answer
14 January 2019 5:50 as a reply to John Doe.
Thank you.
The part for finding data is ok.
For downloading data I did used wget with --user and --password and it didn't work. Still need the "Token" variable for downloading. Is there a manual for this or this step is done only from Web/Chrome ?
Thank you
0 (0 Votes)

RE: PHP login to EO finder
Answer
14 January 2019 1:18 as a reply to SASU SEBASTIAN ANDREI.
Hello,
Please use the following:
1234567
curl \
  -d 'client_id=CLOUDFERRO_PUBLIC' \
  -d 'username=YOUR_USERNAME' \
  -d 'password=YOUR_PASSWORD' \
  -d 'grant_type=password' \
  'https://auth.creodias.eu/auth/realms/DIAS/protocol/openid-connect/token' \
  | python -m json.tool

or this (Python):
123456789101112131415161718
import requests
import json

def get_keycloak_token():
    h = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    d = {
        'client_id': 'CLOUDFERRO_PUBLIC',
        'password': 'YOUR_PASSWORD',
        'username': 'YOUR_USERNAME',
        'grant_type': 'password'
    }
    resp = requests.post('https://auth.creodias.eu/auth/realms/dias/protocol/openid-connect/token', data=d, headers=h)
    return json.loads(resp.content.decode('utf-8'))['access_token']

if __name__ == "__main__":
    print (get_keycloak_token())
Regards,
Marcin Gil
0 (0 Votes)