示例#1
0
		public new void Initialize()
		{
			var remoteBridge = new RemoteHueClient("test");
			//remoteBridge.Initialize("bridgeId");

			_client = remoteBridge;
		}
示例#2
0
		public new void Initialize()
		{
			IRemoteHueClient remoteBridge = new RemoteHueClient("test");
			remoteBridge.Initialize("bridgeId", "key");

			_client = remoteBridge;
		}
示例#3
0
        async void Button_Clicked(System.Object sender, System.EventArgs e)
        {
            IRemoteAuthenticationClient authClient = new RemoteAuthenticationClient("", "", "");
            var authUri = authClient.BuildAuthorizeUri("sample", "myhue");

            var authResult = await WebAuthenticator.AuthenticateAsync(
                new Uri(authUri.AbsoluteUri),
                new Uri("mymeetings://"));

            var code = authResult?.Properties.FirstOrDefault(x => x.Key == "code").Value;

            if (String.IsNullOrEmpty(code))
            {
                return;
            }

            var accessToken = await authClient.GetToken(code);

            IRemoteHueClient client = new RemoteHueClient(authClient.GetValidToken);
            var bridges             = await client.GetBridgesAsync();

            var currentBridge = bridges.FirstOrDefault().Id;

            try
            {
                //var key = await client.RegisterAsync(bridges.First().Id, "Sample App");
                client.Initialize(bridges.First().Id, "");
                var lights = await client.GetLightsAsync();

                var lightResult = await client.SendCommandAsync(new LightCommand().TurnOff());
            }
            catch (Exception ex)
            {
            }
        }
        public new void Initialize()
        {
            IRemoteHueClient remoteBridge = new RemoteHueClient(GetTestAccessToken);

            remoteBridge.Initialize("bridgeId", "key");

            _client = remoteBridge;
        }
示例#5
0
        public new void Initialize()
        {
            var remoteBridge = new RemoteHueClient("test");

            //remoteBridge.Initialize("bridgeId");

            _client = remoteBridge;
        }
示例#6
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            //Fill with values provided on https://developers.meethue.com/my-apps/
            string appId        = ""; //q42-hueapi-test
            string clientId     = "";
            string clientSecret = "";
            var    callbackUri  = new Uri(""); //https://localhost/q42hueapitest

            IRemoteAuthenticationClient authClient = new RemoteAuthenticationClient(clientId, clientSecret, appId);

            //If you already have an accessToken, call:
            //AccessTokenResponse storedAccessToken = SomehwereFrom.Storage();
            //authClient.Initialize(storedAccessToken);
            //IRemoteHueClient client = new RemoteHueClient(authClient.GetValidToken);

            //Else, reinitialize:

            var authorizeUri = authClient.BuildAuthorizeUri("sample", "consoleapp");

            var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, authorizeUri, callbackUri);

            if (webAuthenticationResult != null)
            {
                var result = authClient.ProcessAuthorizeResponse(webAuthenticationResult.ResponseData);

                if (!string.IsNullOrEmpty(result.Code))
                {
                    //You can store the accessToken for later use
                    var accessToken = await authClient.GetToken(result.Code);

                    IRemoteHueClient client = new RemoteHueClient(authClient.GetValidToken);
                    var bridges             = await client.GetBridgesAsync();

                    if (bridges != null)
                    {
                        //Register app
                        //var key = await client.RegisterAsync(bridges.First().Id, "Sample App");

                        //Or initialize with saved key:
                        client.Initialize(bridges.First().Id, "C95sK6Cchq2LfbkbVkfpRKSBlns2CylN-VxxDD8F");

                        //Turn all lights on
                        var lightResult = await client.SendCommandAsync(new LightCommand().TurnOn());
                    }
                }
            }
        }
示例#7
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string appId        = "";
            string clientId     = "";
            string clientSecret = "";

            IRemoteAuthenticationClient authClient = new RemoteAuthenticationClient(clientId, clientSecret, appId);
            var authorizeUri = authClient.BuildAuthorizeUri("sample", "consoleapp");
            var callbackUri  = new Uri("https://localhost/q42hueapi");

            var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, authorizeUri, callbackUri);

            if (webAuthenticationResult != null)
            {
                var result = authClient.ProcessAuthorizeResponse(webAuthenticationResult.ResponseData);

                if (!string.IsNullOrEmpty(result.Code))
                {
                    var accessToken = await authClient.GetToken(result.Code);

                    //var refreshedToken = await authClient.RefreshToken(accessToken.Refresh_token);

                    IRemoteHueClient client = new RemoteHueClient(authClient.GetValidToken);
                    var bridges             = await client.GetBridgesAsync();

                    if (bridges != null)
                    {
                        //Register app
                        //var key = await client.RegisterAsync(bridges.First().Id, "Sample App");

                        //Or initialize with saved key:
                        client.Initialize(bridges.First().Id, "C95sK6Cchq2LfbkbVkfpRKSBlns2CylN-VxxDD8F");

                        //Turn all lights on
                        var lightResult = await client.SendCommandAsync(new LightCommand().TurnOn());
                    }
                }
            }
        }