@maxim_mazurok/gapi.client.smartdevicemanagement-v1
v0.0.20241029
Published
TypeScript typings for Smart Device Management API v1
Downloads
4,517
Readme
TypeScript typings for Smart Device Management API v1
Allow select enterprise partners to access, control, and manage Google and Nest devices programmatically. For detailed description please check documentation.
Installing
Install typings for Smart Device Management API:
npm install @types/gapi.client.smartdevicemanagement-v1 --save-dev
Usage
You need to initialize Google API client in your code:
gapi.load('client', () => {
// now we can use gapi.client
// ...
});
Then load api client wrapper:
gapi.client.load(
'https://smartdevicemanagement.googleapis.com/$discovery/rest?version=v1',
() => {
// now we can use:
// gapi.client.smartdevicemanagement
}
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('smartdevicemanagement', 'v1', () => {
// now we can use:
// gapi.client.smartdevicemanagement
});
Don't forget to authenticate your client before sending any request to resources:
// declare client_id registered in Google Developers Console
var client_id = '',
scope = [
// See and/or control the devices that you selected
'https://www.googleapis.com/auth/sdm.service',
],
immediate = true;
// ...
gapi.auth.authorize(
{client_id: client_id, scope: scope, immediate: immediate},
authResult => {
if (authResult && !authResult.error) {
/* handle successful authorization */
} else {
/* handle authorization error */
}
}
);
After that you can use Smart Device Management API resources: