public static CloudIotService CreateAuthorizedClient()
{
GoogleCredential credential =
GoogleCredential.GetApplicationDefaultAsync().Result;
// Inject the Cloud IoT Core Service scope
if (credential.IsCreateScopedRequired)
{
credential = credential.CreateScoped(new[]
{
CloudIotService.Scope.CloudPlatform // Used for IoT + PubSub + IAM
//CloudIotService.Scope.Cloudiot // Can be used if not accessing Pub/Sub
});
}
return new CloudIotService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
GZipEnabled = false
});
}
Weitere Informationen
Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.