End User Authentication with OAuth
Obtain your token through https://login.meteomatics.com/api/v1/token by using basic authentication with your username and password.
For example, using javascript:username='yourUsername'
password='ABCDeij953ad'
let headers = new Headers();
headers.set('Authorization', 'Basic ' + btoa(username + ":" + password));
fetch('https://login.meteomatics.com/api/v1/token', {
method: 'GET', headers: headers
}).then(function (resp) {
return resp.json();
}).then(function (data) {
var token = data.access_token;
console.log('token', token);
}).catch(function (err) {
console.log('something went wrong', err);
});
It will print a token such as:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiO...SMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
The obtained token is valid for 2 hours and can be used to authenticate your queries:
https://api.meteomatics.com/mvt/isolines/2024-10-31T0Z/msl_pressure.hPa/style.json?access_token=eyJ0...PGw