Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

The following code can be used to retrieve a token and request the list of service locations accessible to the current account:

var test = async () => {
	let formData = new URLSearchParams();
	formData.append('grant_type', 'password');
	formData.append('username', '{{username}}');
	formData.append('password', '{{password}}');
	formData.append('client_id', '{{client_id}});
	formData.append('client_secret', '{{client_secret}}');

	const tokens = await fetch('https://farm1pub.smappee.net/dev/v3/oauth2/token', { method: 'POST', body: formData })
		.then(response => response.json());

	const accessToken = tokens.access_token;
	const result = await fetch('https://farm1pub.smappee.net/dev/v3/servicelocation', { headers: { Authorization: 'Bearer ' + accessToken } })

		.then(response => response.json());

	console.log(result);
}; test();

  • No labels