Dart Toit API
This package provides gRPC functions to access the Toit server through its APIs.
Example
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:grpc/grpc.dart';
import 'package:toit_api/toit/api/auth.pbgrpc.dart';
/**
* This application demonstrates logging in with a user-name password.
*/
Future<void> main(List<String> args) async {
if (args.length != 2) {
print("Usage: username_pw.dart <user-name> <password>");
exit(1);
}
var username = args[0];
var password = args[1];
var channel = ClientChannel('api.toit.io');
try {
print("Logging in...");
var authStub = AuthClient(channel);
var resp = await authStub
.login(LoginRequest(username: username, password: password));
var tokenBytes = resp.accessToken;
var token = utf8.decode(tokenBytes);
// The received token must be used in the `options` of all other stubs.
var options = CallOptions(metadata: {'Authorization': 'Bearer ${token}'});
print("Logging out...");
var authorizedClientStub = AuthClient(channel, options: options);
await authorizedClientStub.logout(LogoutRequest());
} finally {
channel.shutdown();
}
}
See more examples in the example
folder.
Resources
The protobuf files for the Toit APIs can be found here. The documentation for the Toit API is here.
Known limitations
This package currently only exposes the generated protobuf APIs. No effort has been made to create a nicer layer around it.
Issues and feedback
Please file issues to send feedback or report a bug. Thank you!.
Libraries
- google/protobuf/any.pb
- google/protobuf/any.pbenum
- google/protobuf/any.pbjson
- google/protobuf/api.pb
- google/protobuf/api.pbenum
- google/protobuf/api.pbjson
- google/protobuf/compiler/plugin.pb
- google/protobuf/compiler/plugin.pbenum
- google/protobuf/compiler/plugin.pbjson
- google/protobuf/descriptor.pb
- google/protobuf/descriptor.pbenum
- google/protobuf/descriptor.pbjson
- google/protobuf/duration.pb
- google/protobuf/duration.pbenum
- google/protobuf/duration.pbjson
- google/protobuf/empty.pb
- google/protobuf/empty.pbenum
- google/protobuf/empty.pbjson
- google/protobuf/field_mask.pb
- google/protobuf/field_mask.pbenum
- google/protobuf/field_mask.pbjson
- google/protobuf/source_context.pb
- google/protobuf/source_context.pbenum
- google/protobuf/source_context.pbjson
- google/protobuf/struct.pb
- google/protobuf/struct.pbenum
- google/protobuf/struct.pbjson
- google/protobuf/timestamp.pb
- google/protobuf/timestamp.pbenum
- google/protobuf/timestamp.pbjson
- google/protobuf/type.pb
- google/protobuf/type.pbenum
- google/protobuf/type.pbjson
- google/protobuf/wrappers.pb
- google/protobuf/wrappers.pbenum
- google/protobuf/wrappers.pbjson
- toit/api/app.pb
- toit/api/app.pbenum
- toit/api/app.pbgrpc
- toit/api/app.pbjson
- toit/api/auth.pb
- toit/api/auth.pbenum
- toit/api/auth.pbgrpc
- toit/api/auth.pbjson
- toit/api/data.pb
- toit/api/data.pbenum
- toit/api/data.pbgrpc
- toit/api/data.pbjson
- toit/api/device.pb
- toit/api/device.pbenum
- toit/api/device.pbgrpc
- toit/api/device.pbjson
- toit/api/doctor.pb
- toit/api/doctor.pbenum
- toit/api/doctor.pbgrpc
- toit/api/doctor.pbjson
- toit/api/hardware.pb
- toit/api/hardware.pbenum
- toit/api/hardware.pbgrpc
- toit/api/hardware.pbjson
- toit/api/organization.pb
- toit/api/organization.pbenum
- toit/api/organization.pbgrpc
- toit/api/organization.pbjson
- toit/api/program.pb
- toit/api/program.pbenum
- toit/api/program.pbgrpc
- toit/api/program.pbjson
- toit/api/pubsub/publish.pb
- toit/api/pubsub/publish.pbenum
- toit/api/pubsub/publish.pbgrpc
- toit/api/pubsub/publish.pbjson
- toit/api/pubsub/subscribe.pb
- toit/api/pubsub/subscribe.pbenum
- toit/api/pubsub/subscribe.pbgrpc
- toit/api/pubsub/subscribe.pbjson
- toit/api/sdk.pb
- toit/api/sdk.pbenum
- toit/api/sdk.pbgrpc
- toit/api/sdk.pbjson
- toit/api/simulator.pb
- toit/api/simulator.pbenum
- toit/api/simulator.pbgrpc
- toit/api/simulator.pbjson
- toit/api/user.pb
- toit/api/user.pbenum
- toit/api/user.pbgrpc
- toit/api/user.pbjson
- toit/model/app.pb
- toit/model/app.pbenum
- toit/model/app.pbjson
- toit/model/data.pb
- toit/model/data.pbenum
- toit/model/data.pbjson
- toit/model/device.pb
- toit/model/device.pbenum
- toit/model/device.pbjson
- toit/model/job.pb
- toit/model/job.pbenum
- toit/model/job.pbjson
- toit/model/organization.pb
- toit/model/organization.pbenum
- toit/model/organization.pbjson
- toit/model/program.pb
- toit/model/program.pbenum
- toit/model/program.pbjson
- toit/model/pubsub/message.pb
- toit/model/pubsub/message.pbenum
- toit/model/pubsub/message.pbjson
- toit/model/pubsub/topic.pb
- toit/model/pubsub/topic.pbenum
- toit/model/pubsub/topic.pbjson