PhilipsHue / HueSDK

Philips Hue Software Development Kit
98 stars 39 forks source link

Android SDK Remote api tutorial #29

Closed tpapagiannis closed 6 years ago

tpapagiannis commented 6 years ago

Hi, i would like to tell me how to use android sdk for using the Remote API. I would like to send me a tutorial code for this. I have declared an app, i have the clientid, client secret etc. Thanks.

jeroenbeuz commented 6 years ago

I would like to get this as well.

tpapagiannis commented 6 years ago

I use the following to setup remote access and pass Username that I took from the Oauth2 process:

Newbridge = new BridgeBuilder("LyfeShieldWellAgeing", android.os.Build.MODEL) // .setIpAddress(bridgeIp) .setConnectionType(BridgeConnectionType.REMOTE) .setBridgeConnectionCallback(bridgeConnectionCallback) .addBridgeStateUpdatedCallback(bridgeStateUpdatedCallback)

    .setupRemote("lyfeshieldwellageing", Build.DEVICE, null, "lyfeshieldapp://huecallback",
            ClientID,  ClientSecret)
     .setUserName(Username)
    .build();

Newbridge.connect();

It does not connect and it gives me the error:

E/HueSDK: PortalConnectionErrorParser: got fault, remote connection error: 0 04-17 13:26:17.577 31878-32395/com.smarts.lyfeshieldwellageing E/HueSDK: PortalConnectionErrorParser: got http code 0

Connection event: LOGIN_REQUIRED 04-18 15:05:35.793 17093-19028/com.smarts.lyfeshieldwellageing I/Praeda: Connection event: COULD_NOT_CONNECT

If i use this code:

// set access_token OAuthTokenPair tokenPair= new OAuthTokenPair(); tokenPair.setAccessToken(prefs.getAccess_Token()); tokenPair.setRefreshToken(prefs.getRefresh_Token()); connection.setAccessTokens(tokenPair);

then it tell me : NO_BRIDGE_FOR_PORTAL_ACCOUNT.

WHAT IS THE PROBLEM WITH MY CODE ?

PLEASE HELP.

jeroenbeuz commented 6 years ago

Its been almost 3 weeks now. This is ridiculous..

jhvdb87 commented 6 years ago

@jeroenbeuz There is no official documentation on the remote API yet. For now you can use the example above. If you encounter a similar issue (NO_BRIDGE_FOR_PORTAL_ACCOUNT) as mentioned by @tpapagiannis, please send an email to philipshuedev@philips.com. They will reconfigure your remote API account.

jeroenbeuz commented 6 years ago

@jhvdb87 Ok I will try that. Thanks.